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



commit 4545bbf3a0090edfd612845d867162ee1a5ec5b5
Author: Sebastian Geiger <sbastig gmx net>
Date:   Tue Jun 9 00:48:25 2015 +0200

    windowpicker/task-item.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 and WnckWindow.

 windowpicker/src/task-item.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/windowpicker/src/task-item.c b/windowpicker/src/task-item.c
index a579290..9b72308 100644
--- a/windowpicker/src/task-item.c
+++ b/windowpicker/src/task-item.c
@@ -719,6 +719,22 @@ static void task_item_setup_atk (TaskItem *item) {
     atk_object_set_role (atk, ATK_ROLE_PUSH_BUTTON);
 }
 
+static void
+task_item_dispose (GObject *object)
+{
+    TaskItem *task_item = TASK_ITEM (object);
+
+    g_signal_handlers_disconnect_by_func (task_item->priv->screen, on_screen_active_viewport_changed, 
task_item);
+    g_signal_handlers_disconnect_by_func (task_item->priv->screen, on_screen_active_window_changed, 
task_item);
+    g_signal_handlers_disconnect_by_func (task_item->priv->screen, on_screen_active_workspace_changed, 
task_item);
+    g_signal_handlers_disconnect_by_func (task_item->priv->screen, on_screen_window_closed, task_item);
+    g_signal_handlers_disconnect_by_func (task_item->priv->window, on_window_workspace_changed, task_item);
+    g_signal_handlers_disconnect_by_func (task_item->priv->window, on_window_state_changed, task_item);
+    g_signal_handlers_disconnect_by_func (task_item->priv->window, on_window_icon_changed, task_item);
+
+    G_OBJECT_CLASS (task_item_parent_class)->dispose (object);
+}
+
 static void task_item_finalize (GObject *object) {
     TaskItemPrivate *priv = TASK_ITEM (object)->priv;
     /* remove timer */
@@ -735,6 +751,7 @@ static void task_item_finalize (GObject *object) {
 static void task_item_class_init (TaskItemClass *klass) {
     GObjectClass *obj_class      = G_OBJECT_CLASS (klass);
     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+    obj_class->dispose = task_item_dispose;
     obj_class->finalize = task_item_finalize;
     widget_class->get_preferred_width = task_item_get_preferred_width;
     widget_class->get_preferred_height = task_item_get_preferred_height;


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