managesieve: fix memory leak
[claws.git] / src / plugins / managesieve / sieve_editor.c
index dc89f7fb2998b23f7ec59ecd86848818ca5dc1b1..2931c8684c9fd9c48e1e93a3c8d44acfb5c55c83 100644 (file)
@@ -41,6 +41,7 @@
 #include "mainwindow.h"
 #include "message_search.h"
 #include "managesieve.h"
+#include "sieve_manager.h"
 #include "sieve_editor.h"
 
 GSList *editors = NULL;
@@ -105,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);
        }
 }
 
@@ -156,12 +158,14 @@ static void sieve_editor_set_status_icon(SieveEditorPage *page, const gchar *img
 }
 
 static void sieve_editor_append_status(SieveEditorPage *page,
-               const gchar *status)
+               const gchar *new_status)
 {
        GtkLabel *label = GTK_LABEL(page->status_text);
        const gchar *prev_status = gtk_label_get_text(label);
        const gchar *sep = prev_status && prev_status[0] ? "\n" : "";
-       gtk_label_set_text(label, g_strconcat(prev_status, sep, status, NULL));
+       gchar *status = g_strconcat(prev_status, sep, new_status, NULL);
+       gtk_label_set_text(label, status);
+       g_free(status);
 }
 
 /* Update the status icon and text from a response. */
@@ -348,6 +352,13 @@ static void got_data_saved(SieveSession *session, gboolean abort,
                if (result->code == SIEVE_CODE_NONE) {
                        result->description = _("Script saved successfully.");
                }
+
+               if (page->is_new) {
+                       /* notify manager windows of newly created script */
+                       page->is_new = FALSE;
+                       sieve_manager_script_created(session,
+                                       page->script_name);
+               }
        }
        sieve_editor_update_status(page, result);
 }