Change component.deregister to take the object as the parameter, not the name
This commit is contained in:
parent
24c945f139
commit
5bc63fa910
|
@ -99,7 +99,7 @@ class Component(object):
|
|||
_ComponentRegistry.register(self)
|
||||
|
||||
def __del__(self):
|
||||
_ComponentRegistry.deregister(self._component_name)
|
||||
_ComponentRegistry.deregister(self)
|
||||
|
||||
def _component_start_timer(self):
|
||||
if hasattr(self, "update"):
|
||||
|
@ -231,22 +231,22 @@ class ComponentRegistry(object):
|
|||
|
||||
self.components[obj._component_name] = obj
|
||||
|
||||
def deregister(self, name):
|
||||
def deregister(self, obj):
|
||||
"""
|
||||
Deregisters a component from the registry. A stop will be
|
||||
issued to the component prior to deregistering it.
|
||||
|
||||
:param name: the name of the component
|
||||
:type name: string
|
||||
:param obj: the Component object
|
||||
:type obj: object
|
||||
|
||||
"""
|
||||
|
||||
if name in self.components:
|
||||
log.debug("Deregistering Component: %s", name)
|
||||
d = self.stop([name])
|
||||
if obj in self.components.values():
|
||||
log.debug("Deregistering Component: %s", obj._component_name)
|
||||
d = self.stop([obj._component_name])
|
||||
def on_stop(result, name):
|
||||
del self.components[name]
|
||||
return d.addCallback(on_stop, name)
|
||||
return d.addCallback(on_stop, obj._component_name)
|
||||
else:
|
||||
return succeed(None)
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ class PluginManagerBase:
|
|||
"""Disables a plugin"""
|
||||
try:
|
||||
self.plugins[name].disable()
|
||||
component.deregister(self.plugins[name].plugin._component_name)
|
||||
component.deregister(self.plugins[name].plugin)
|
||||
del self.plugins[name]
|
||||
self.config["enabled_plugins"].remove(name)
|
||||
except KeyError:
|
||||
|
|
|
@ -94,7 +94,7 @@ class ComponentTestClass(unittest.TestCase):
|
|||
|
||||
def finish_start_with_depends(self, *args):
|
||||
for c in args[1:]:
|
||||
component.deregister(c._component_name)
|
||||
component.deregister(c)
|
||||
|
||||
def test_start_all(self):
|
||||
def on_start(*args):
|
||||
|
|
|
@ -88,7 +88,7 @@ class SessionProxyTestCase(unittest.TestCase):
|
|||
return d
|
||||
|
||||
def tearDown(self):
|
||||
return component.deregister("SessionProxy")
|
||||
return component.deregister(self.sp)
|
||||
|
||||
def test_startup(self):
|
||||
self.assertEquals(client.core.torrents["a"], self.sp.torrents["a"][1])
|
||||
|
|
|
@ -418,7 +418,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||
|
||||
def back_to_overview(self):
|
||||
component.stop(["TorrentDetail"])
|
||||
component.deregister("TorrentDetail")
|
||||
component.deregister(self)
|
||||
self.stdscr.clear()
|
||||
component.get("ConsoleUI").set_mode(self.alltorrentmode)
|
||||
self.alltorrentmode.resume()
|
||||
|
|
Loading…
Reference in New Issue