Jakub Filak bc9671
From 25a3f7f6f61e387d903e4e1547ad91184131dd8e Mon Sep 17 00:00:00 2001
Jakub Filak bc9671
From: Jakub Filak <jfilak@redhat.com>
Jakub Filak bc9671
Date: Thu, 19 Mar 2015 13:58:16 +0100
Jakub Filak bc9671
Subject: [PATCH] applet: fix freeing of the notify problem list
Jakub Filak bc9671
Jakub Filak bc9671
The functions that process the list also frees the list.
Jakub Filak bc9671
Jakub Filak bc9671
Signed-off-by: Jakub Filak <jfilak@redhat.com>
Jakub Filak bc9671
---
Jakub Filak bc9671
 src/applet/applet.c | 24 ++++++++++++++++--------
Jakub Filak bc9671
 1 file changed, 16 insertions(+), 8 deletions(-)
Jakub Filak bc9671
Jakub Filak bc9671
diff --git a/src/applet/applet.c b/src/applet/applet.c
Jakub Filak bc9671
index b471dbc..0cf9b49 100644
Jakub Filak bc9671
--- a/src/applet/applet.c
Jakub Filak bc9671
+++ b/src/applet/applet.c
Jakub Filak bc9671
@@ -87,11 +87,17 @@ static bool is_networking_enabled(void)
Jakub Filak bc9671
 static void show_problem_list_notification(GList *problems);
Jakub Filak bc9671
 static void problem_info_unref(gpointer data);
Jakub Filak bc9671
 
Jakub Filak bc9671
-static gboolean process_deferred_queue_timeout_fn(GList *queue)
Jakub Filak bc9671
+static gboolean process_deferred_queue_timeout_fn(void)
Jakub Filak bc9671
 {
Jakub Filak bc9671
     g_deferred_timeout = 0;
Jakub Filak bc9671
-    show_problem_list_notification(queue);
Jakub Filak bc9671
-    g_list_free_full (queue, problem_info_unref);
Jakub Filak bc9671
+
Jakub Filak bc9671
+    GList *tmp = g_deferred_crash_queue;
Jakub Filak bc9671
+    g_deferred_crash_queue = NULL;
Jakub Filak bc9671
+
Jakub Filak bc9671
+    /* this function calls push_to_deferred_queue() which appends data to
Jakub Filak bc9671
+     * g_deferred_crash_queue but the function also modifies the argument
Jakub Filak bc9671
+     * so we must reset g_deferred_crash_queue before the call */
Jakub Filak bc9671
+    show_problem_list_notification(tmp);
Jakub Filak bc9671
 
Jakub Filak bc9671
     /* Remove this timeout fn from the main loop*/
Jakub Filak bc9671
     return G_SOURCE_REMOVE;
Jakub Filak bc9671
@@ -107,8 +113,7 @@ static void connectivity_changed_cb(GObject    *gobject,
Jakub Filak bc9671
         if (g_deferred_timeout)
Jakub Filak bc9671
             g_source_remove(g_deferred_timeout);
Jakub Filak bc9671
 
Jakub Filak bc9671
-        g_deferred_timeout = g_idle_add ((GSourceFunc)process_deferred_queue_timeout_fn,
Jakub Filak bc9671
-                                         g_deferred_crash_queue);
Jakub Filak bc9671
+        g_deferred_timeout = g_idle_add ((GSourceFunc)process_deferred_queue_timeout_fn, NULL);
Jakub Filak bc9671
     }
Jakub Filak bc9671
 }
Jakub Filak bc9671
 
Jakub Filak bc9671
@@ -583,6 +588,9 @@ add_restart_app_button (NotifyNotification *notification,
Jakub Filak bc9671
             problem_info_ref (pi), problem_info_unref);
Jakub Filak bc9671
 }
Jakub Filak bc9671
 
Jakub Filak bc9671
+/*
Jakub Filak bc9671
+ * Destroys the problems argument
Jakub Filak bc9671
+ */
Jakub Filak bc9671
 static void notify_problem_list(GList *problems)
Jakub Filak bc9671
 {
Jakub Filak bc9671
     if (problems == NULL)
Jakub Filak bc9671
@@ -890,6 +898,9 @@ static void run_event_async(problem_info_t *pi, const char *event_name)
Jakub Filak bc9671
                    handle_event_output_cb, state);
Jakub Filak bc9671
 }
Jakub Filak bc9671
 
Jakub Filak bc9671
+/*
Jakub Filak bc9671
+ * Destroys the problems argument
Jakub Filak bc9671
+ */
Jakub Filak bc9671
 static void show_problem_list_notification(GList *problems)
Jakub Filak bc9671
 {
Jakub Filak bc9671
     if (is_autoreporting_enabled())
Jakub Filak bc9671
@@ -1086,10 +1097,7 @@ next:
Jakub Filak bc9671
     }
Jakub Filak bc9671
 
Jakub Filak bc9671
     if (notify_list)
Jakub Filak bc9671
-    {
Jakub Filak bc9671
         show_problem_list_notification(notify_list);
Jakub Filak bc9671
-        g_list_free_full (notify_list, problem_info_unref);
Jakub Filak bc9671
-    }
Jakub Filak bc9671
 
Jakub Filak bc9671
     list_free_with_free(new_dirs);
Jakub Filak bc9671
 
Jakub Filak bc9671
-- 
Jakub Filak bc9671
2.3.2
Jakub Filak bc9671