managesieve: close windows when unloading
authorCharles Lehner <charles@claws-mail.org>
Tue, 21 Jul 2015 02:23:15 +0000 (22:23 -0400)
committerCharles Lehner <charles@claws-mail.org>
Tue, 21 Jul 2015 02:31:01 +0000 (22:31 -0400)
fixes crash on plugin unload

src/plugins/managesieve/sieve_editor.c
src/plugins/managesieve/sieve_editor.h
src/plugins/managesieve/sieve_manager.c
src/plugins/managesieve/sieve_manager.h
src/plugins/managesieve/sieve_plugin.c

index e085dcb..f8b43ee 100644 (file)
@@ -106,8 +106,9 @@ static GtkActionEntry sieve_editor_entries[] =
 void sieve_editors_close()
 {
        if (editors) {
-               g_slist_free_full(editors, (GDestroyNotify)sieve_editor_close);
+               GSList *list = editors;
                editors = NULL;
+               g_slist_free_full(list, (GDestroyNotify)sieve_editor_close);
        }
 }
 
index 60d3d86..18228c4 100644 (file)
@@ -45,6 +45,7 @@ struct SieveEditorPage
        gpointer on_load_error_data;
 };
 
+void sieve_editors_close();
 SieveEditorPage *sieve_editor_new(SieveSession *session, gchar *script_name);
 SieveEditorPage *sieve_editor_get(SieveSession *session, gchar *script_name);
 void sieve_editor_load(SieveEditorPage *page,
index b2bff52..2dcdf71 100644 (file)
@@ -80,6 +80,13 @@ static GSList *manager_pages = NULL;
                if ((page = (SieveManagerPage *)cur->data) && \
                        page->active_session == session)
 
+void sieve_managers_done()
+{
+       GSList *list = manager_pages;
+       manager_pages = NULL;
+       g_slist_free_full(list, (GDestroyNotify)sieve_manager_done);
+}
+
 static void filters_list_clear(SieveManagerPage *page)
 {
        GtkListStore *list_store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(page->filters_list)));
index 58f08f0..fb5c9ba 100644 (file)
@@ -36,6 +36,7 @@ struct SieveManagerPage
        gboolean        got_list;
 };
 
+void sieve_managers_done(void);
 void sieve_manager_show(void);
 void sieve_manager_done(SieveManagerPage *page);
 void sieve_manager_script_created(SieveSession *session,
index 363a584..09264fc 100644 (file)
@@ -31,6 +31,7 @@
 #include "log.h"
 #include "sieve_prefs.h"
 #include "sieve_manager.h"
+#include "sieve_editor.h"
 
 #define PLUGIN_NAME (_("ManageSieve"))
 
@@ -84,6 +85,8 @@ gboolean plugin_done(void)
        MainWindow *mainwin = mainwindow_get_mainwindow();
 
        sieve_prefs_done();
+       sieve_managers_done();
+       sieve_editors_close();
        sieve_sessions_close();
 
        if (mainwin)