From 7857ebea0ae32984c40de704de05a90925ccd739 Mon Sep 17 00:00:00 2001
From: lovetox <philipp@hoerist.com>
Date: Sat, 28 May 2022 09:48:41 +0200
Subject: [PATCH] fix: Plugins: Unregister modules after calling deactivate()

---
 gajim/plugins/pluginmanager.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gajim/plugins/pluginmanager.py b/gajim/plugins/pluginmanager.py
index 4c9a15e021..258d04f59e 100644
--- a/gajim/plugins/pluginmanager.py
+++ b/gajim/plugins/pluginmanager.py
@@ -543,10 +543,12 @@ def deactivate_plugin(self, plugin: GajimPlugin) -> None:
 
         self._remove_events_handler_from_ged(plugin)
         self._remove_name_from_encryption_plugins(plugin)
-        self._unregister_modules_with_handlers(plugin)
 
-        # removing plug-in from active plug-ins list
+        # deactivate() must be before _unregister_modules_with_handlers(),
+        # because plugin.deactivate() may want to use the module
         plugin.deactivate()
+
+        self._unregister_modules_with_handlers(plugin)
         self.active_plugins.remove(plugin)
         app.settings.set_plugin_setting(plugin.manifest.short_name,
                                         'active',
-- 
GitLab