Fix for dynamic loading and unloading of plugins
Need to add and remove thread jobs
This commit is contained in:
parent
26f2c757d3
commit
f9047c6df0
|
@ -73,6 +73,8 @@ class Plugins:
|
|||
# Inform the plugin of our windows
|
||||
for window in self.windows:
|
||||
plugin.on_new_window(window)
|
||||
if self.network:
|
||||
self.network.add_jobs(plugin.thread_jobs())
|
||||
self.plugins[name] = plugin
|
||||
self.print_error("loaded", name)
|
||||
return plugin
|
||||
|
@ -81,6 +83,10 @@ class Plugins:
|
|||
traceback.print_exc(file=sys.stdout)
|
||||
return None
|
||||
|
||||
def close_plugin(self, plugin):
|
||||
if self.network:
|
||||
self.network.remove_jobs(plugin.thread_jobs())
|
||||
|
||||
def toggle_enabled(self, config, name):
|
||||
p = self.get(name)
|
||||
config.set_key('use_' + name, p is None, True)
|
||||
|
@ -199,6 +205,7 @@ class BasePlugin:
|
|||
l = hooks.get(k, [])
|
||||
l.remove((self, getattr(self, k)))
|
||||
hooks[k] = l
|
||||
self.parent.close_plugin(self)
|
||||
|
||||
def print_error(self, *msg):
|
||||
print_error("[%s]"%self.name, *msg)
|
||||
|
|
Loading…
Reference in New Issue