From f9047c6df0f7463e793d5980df31e08743302f52 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 6 Sep 2015 19:35:14 +0900 Subject: [PATCH] Fix for dynamic loading and unloading of plugins Need to add and remove thread jobs --- lib/plugins.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/plugins.py b/lib/plugins.py index 5416cb49b..4aa0e2f98 100644 --- a/lib/plugins.py +++ b/lib/plugins.py @@ -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)