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