OSDN Git Service

Got ride of the _runningAddons global variable. We can get loaded addons by filtering...
authorrui Batista <ruiandrebatista@gmail.com>
Sun, 22 Apr 2012 14:06:56 +0000 (15:06 +0100)
committerrui Batista <ruiandrebatista@gmail.com>
Sun, 22 Apr 2012 14:06:56 +0000 (15:06 +0100)
Further than addons that could not be loaded for some reason (code errors, damaged files, etc) if we want to support activation and deactivation of specific addons without removal from the first system, this separation is needed.

source/addonHandler.py

index 3715868..a76093e 100644 (file)
@@ -33,28 +33,23 @@ _runningAddons = []
 def getRunningAddons():
        """ Returns currently loaded addons.
        """
-       return iter(_runningAddons)
+       return itertools.ifilter(lambda a : a.isLoaded, getAvailableAddons())
 
 def initialize():
        """ Initializes the add-ons subsystem. """
-       global _runningAddons
-       _runningAddons = []
        for addon in getAvailableAddons():
                try:
                        addon.load()
                except:
                        log.exception("Error loading addon.")
                        continue
-               _runningAddons.append(addon)
                log.debug("Loadded addon from %s", addon.path) 
 
 def terminate():
        """ Terminates the add-ons subsystem. """
-       global _runningAddons
        addons = getRunningAddons()
        for addon in addons:
                addon.unload()
-       _runningAddons = []
 
 
 def runHook(hookName, *args, **kwargs):