diff --git a/moo.kdevelop b/moo.kdevelop index 5fc2402e..970aff48 100644 --- a/moo.kdevelop +++ b/moo.kdevelop @@ -292,16 +292,16 @@ - + A new empty GAP source file - + A new empty C++ file. - + A new empty header file for C/C++. - + A new empty C file. diff --git a/moo/mooapp/mooapp.c b/moo/mooapp/mooapp.c index c85f72c8..c7ffa0be 100644 --- a/moo/mooapp/mooapp.c +++ b/moo/mooapp/mooapp.c @@ -1055,6 +1055,9 @@ moo_app_quit_real (MooApp *app) #ifdef MOO_BUILD_EDIT moo_editor_close_all (app->priv->editor, TRUE); + + moo_plugin_shutdown (); + g_object_unref (app->priv->editor); app->priv->editor = NULL; #endif /* MOO_BUILD_EDIT */ diff --git a/moo/mooedit/mooplugin.c b/moo/mooedit/mooplugin.c index 3ad83024..de17f400 100644 --- a/moo/mooedit/mooplugin.c +++ b/moo/mooedit/mooplugin.c @@ -979,6 +979,48 @@ moo_plugin_read_dirs (void) } +void +moo_plugin_shutdown (void) +{ + GSList *list; + + if (!plugin_store || !plugin_store->dirs_read) + return; + + list = g_slist_copy (plugin_store->list); + g_slist_foreach (list, (GFunc) g_object_ref, NULL); + + while (list) + { + moo_plugin_unregister (G_OBJECT_TYPE (list->data)); + g_object_unref (list->data); + list = g_slist_delete_link (list, list); + } + +#ifdef MOO_USE_PYGTK + _moo_python_plugin_deinit (); +#endif + + plugin_store->dirs_read = FALSE; + plugin_store->editor = NULL; + + if (plugin_store->list) + { + g_critical ("%s: could not unregister all plugins", G_STRLOC); + g_slist_free (plugin_store->list); + plugin_store->list = NULL; + } + + g_hash_table_destroy (plugin_store->names); + plugin_store->names = NULL; + + g_strfreev (plugin_store->dirs); + plugin_store->dirs = NULL; + + plugin_store = NULL; +} + + void _moo_window_attach_plugins (MooEditWindow *window) { diff --git a/moo/mooedit/mooplugin.h b/moo/mooedit/mooplugin.h index 5676c032..8fd192a1 100644 --- a/moo/mooedit/mooplugin.h +++ b/moo/mooedit/mooplugin.h @@ -212,6 +212,7 @@ const char *moo_plugin_version (MooPlugin *plugin); char **moo_plugin_get_dirs (void); void moo_plugin_read_dirs (void); +void moo_plugin_shutdown (void); void moo_plugin_set_info (MooPlugin *plugin, MooPluginInfo *info); diff --git a/moo/moopython/mooplugin-python.c b/moo/moopython/mooplugin-python.c index e8ff8989..747cbc4b 100644 --- a/moo/moopython/mooplugin-python.c +++ b/moo/moopython/mooplugin-python.c @@ -370,6 +370,15 @@ _moo_python_plugin_init (void) } +void +_moo_python_plugin_deinit (void) +{ + Py_XDECREF (main_mod); + main_mod = NULL; + moo_python_init (MOO_PY_API_VERSION, NULL); +} + + #ifdef MOO_PYTHON_PLUGIN MOO_PLUGIN_INIT_FUNC_DECL; MOO_PLUGIN_INIT_FUNC_DECL diff --git a/moo/moopython/mooplugin-python.h b/moo/moopython/mooplugin-python.h index e40e4c96..e9d9c0fc 100644 --- a/moo/moopython/mooplugin-python.h +++ b/moo/moopython/mooplugin-python.h @@ -19,7 +19,8 @@ G_BEGIN_DECLS -gboolean _moo_python_plugin_init (void); +gboolean _moo_python_plugin_init (void); +void _moo_python_plugin_deinit (void); G_END_DECLS