[gnome-applets/wip/segeiger/window-picker-in-process] windowpicker/task-list.c: Fix segfault during object destruction



commit 60a9a01d43719dedd9101312b0e78b3db4f0d9a3
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sun Jun 7 14:45:01 2015 +0200

    windowpicker/task-list.c: Fix segfault during object destruction
    
    When the object is destroyed the the signal handlers
    need to be properly disconnected to avoid that they
    are called after the object has already been destroyed.

 windowpicker/src/task-list.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/windowpicker/src/task-list.c b/windowpicker/src/task-list.c
index 81c1408..f9047f8 100644
--- a/windowpicker/src/task-list.c
+++ b/windowpicker/src/task-list.c
@@ -67,15 +67,6 @@ static void on_window_opened (WnckScreen *screen,
     }
 }
 
-/* GObject stuff */
-static void task_list_finalize (GObject *object) {
-    TaskListPrivate *priv = TASK_LIST (object)->priv;
-    /* Remove the blink timer */
-    if (priv->timer) g_source_remove (priv->timer);
-
-    G_OBJECT_CLASS (task_list_parent_class)->finalize (object);
-}
-
 static void on_task_list_orient_changed(PanelApplet *applet,
                                         guint orient,
                                         GtkBox *box)
@@ -97,10 +88,30 @@ static void on_task_list_orient_changed(PanelApplet *applet,
     gtk_widget_queue_resize(GTK_WIDGET(box));
 }
 
+/* GObject stuff */
+static void task_list_dispose(GObject *object) {
+    g_return_if_fail(TASK_IS_LIST(object));
+    TaskList *task_list = TASK_LIST(object);
+    g_signal_handlers_disconnect_by_func(task_list, on_task_list_orient_changed, task_list);
+    g_signal_handlers_disconnect_by_func(task_list, on_window_opened, task_list);
+}
+
+static void task_list_finalize (GObject *object) {
+    g_return_if_fail(TASK_IS_LIST(object));
+    TaskList *task_list = TASK_LIST(object);
+    TaskListPrivate *priv = task_list->priv;
+
+    /* Remove the blink timer */
+    if (priv->timer) g_source_remove (priv->timer);
+
+    G_OBJECT_CLASS (task_list_parent_class)->finalize (object);
+}
+
 static void
 task_list_class_init(TaskListClass *class) {
     GObjectClass *obj_class = G_OBJECT_CLASS (class);
 
+    obj_class->dispose = task_list_dispose;
     obj_class->finalize = task_list_finalize;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]