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
|
# Inform the plugin of our windows
|
||||||
for window in self.windows:
|
for window in self.windows:
|
||||||
plugin.on_new_window(window)
|
plugin.on_new_window(window)
|
||||||
|
if self.network:
|
||||||
|
self.network.add_jobs(plugin.thread_jobs())
|
||||||
self.plugins[name] = plugin
|
self.plugins[name] = plugin
|
||||||
self.print_error("loaded", name)
|
self.print_error("loaded", name)
|
||||||
return plugin
|
return plugin
|
||||||
|
@ -81,6 +83,10 @@ class Plugins:
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def close_plugin(self, plugin):
|
||||||
|
if self.network:
|
||||||
|
self.network.remove_jobs(plugin.thread_jobs())
|
||||||
|
|
||||||
def toggle_enabled(self, config, name):
|
def toggle_enabled(self, config, name):
|
||||||
p = self.get(name)
|
p = self.get(name)
|
||||||
config.set_key('use_' + name, p is None, True)
|
config.set_key('use_' + name, p is None, True)
|
||||||
|
@ -199,6 +205,7 @@ class BasePlugin:
|
||||||
l = hooks.get(k, [])
|
l = hooks.get(k, [])
|
||||||
l.remove((self, getattr(self, k)))
|
l.remove((self, getattr(self, k)))
|
||||||
hooks[k] = l
|
hooks[k] = l
|
||||||
|
self.parent.close_plugin(self)
|
||||||
|
|
||||||
def print_error(self, *msg):
|
def print_error(self, *msg):
|
||||||
print_error("[%s]"%self.name, *msg)
|
print_error("[%s]"%self.name, *msg)
|
||||||
|
|
Loading…
Reference in New Issue