[geany/geany-plugins] 625e29: GeanyPy: Unload Python plugins when GeanyPy is deactivated

Matthew Brush git-noreply at xxxxx
Sun Jul 12 05:01:37 UTC 2015


Branch:      refs/tags/1.25
Author:      Matthew Brush <mbrush at codebrainz.ca>
Committer:   Matthew Brush <mbrush at codebrainz.ca>
Date:        Sun, 12 Jul 2015 05:01:37 UTC
Commit:      625e29e8cc5fca8085029b82055b32ef1c6dd53d
             https://github.com/geany/geany-plugins/commit/625e29e8cc5fca8085029b82055b32ef1c6dd53d

Log Message:
-----------
GeanyPy: Unload Python plugins when GeanyPy is deactivated

This prevents crashes and/or lockups when the GeanyPy C plugin
is reloaded.

FIXME: Because it calls the normal unloading path, it updates
the list of loaded plugins to remove each plugin. The net effect
is that when the C GeanyPy plugin is unloaded, it forgets all
of the Python plugins that were loaded at the time.


Modified Paths:
--------------
    geanypy/geany/manager.py
    geanypy/src/geanypy-plugin.c

Modified: geanypy/geany/manager.py
3 lines changed, 3 insertions(+), 0 deletions(-)
===================================================================
@@ -93,6 +93,9 @@ def activate_plugin(self, filename):
 	def deactivate_plugin(self, filename):
 		self.loader.unload_plugin(filename)
 
+	def deactivate_all_plugins(self):
+		self.response(gtk.RESPONSE_CLOSE)
+		self.loader.unload_all_plugins()
 
 	def load_plugins_list(self):
 		liststore = gtk.ListStore(gobject.TYPE_BOOLEAN, str, str)


Modified: geanypy/src/geanypy-plugin.c
11 lines changed, 11 insertions(+), 0 deletions(-)
===================================================================
@@ -278,6 +278,17 @@ plugin_init(GeanyData *data)
 
 G_MODULE_EXPORT void plugin_cleanup(void)
 {
+    PyObject* deactivate_all_plugins = PyObject_GetAttrString(manager,
+            "deactivate_all_plugins");
+    if (deactivate_all_plugins != NULL)
+    {
+        PyObject* r = PyObject_CallObject(deactivate_all_plugins, NULL);
+        if (r)
+            Py_DECREF(r);
+        Py_DECREF(deactivate_all_plugins);
+
+    }
+
     signal_manager_free(signal_manager);
     Py_XDECREF(manager);
 	GeanyPy_stop_interpreter();



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list