[gnome-applets/wip/segeiger/window-picker-in-process: 6/11] windowpicker/task-list.c: Properly disconnect signal handlers in dispose function



commit b10f9757d6b0e45730ae9e803f8fcbb8c9e1a7c7
Author: Sebastian Geiger <sbastig gmx net>
Date:   Tue Jun 9 00:50:10 2015 +0200

    windowpicker/task-list.c: Properly disconnect signal handlers in dispose function
    
    When the object is destroyed the signal handlers
    need to be properly disconnected to avoid that they
    are called after the object has already been destroyed.
    
    This only affects signal handlers that are not related to the object itself,
    such as for WnckScreen.

 windowpicker/src/task-list.c |   33 ++++++++++++++++++++++++---------
 1 files changed, 24 insertions(+), 9 deletions(-)
---
diff --git a/windowpicker/src/task-list.c b/windowpicker/src/task-list.c
index 81c1408..4ed0962 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)
@@ -98,9 +89,33 @@ static void on_task_list_orient_changed(PanelApplet *applet,
 }
 
 static void
+task_list_dispose (GObject *object)
+{
+    TaskList *task_list = TASK_LIST (object);
+    g_signal_handlers_disconnect_by_func (task_list->priv->screen, on_window_opened, task_list);
+
+    G_OBJECT_CLASS (task_list_parent_class)->dispose (object);
+}
+
+static void
+task_list_finalize (GObject *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]