[gegl-gtk] Disconnect signal handlers when replacing node (bug 750943)



commit cda2bdb5291f169a858ab21754f4206d14bb4c9e
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Jun 14 19:37:41 2015 +0200

    Disconnect signal handlers when replacing node (bug 750943)

 gegl-gtk/internal/view-helper.c |   22 ++++++++++++++--------
 gegl-gtk/internal/view-helper.h |    3 +++
 2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/gegl-gtk/internal/view-helper.c b/gegl-gtk/internal/view-helper.c
index 98289fd..8df99e0 100644
--- a/gegl-gtk/internal/view-helper.c
+++ b/gegl-gtk/internal/view-helper.c
@@ -334,19 +334,22 @@ view_helper_set_node(ViewHelper *self, GeglNode *node)
     if (self->node == node)
         return;
 
-    if (self->node)
+    if (self->node) {
+        g_signal_handler_disconnect (self->node, self->computed_id);
+        g_signal_handler_disconnect (self->node, self->invalidated_id);
         g_object_unref(self->node);
+    }
 
     if (node) {
         g_object_ref(node);
         self->node = node;
 
-        g_signal_connect_object(self->node, "computed",
-                                G_CALLBACK(computed_event),
-                                self, 0);
-        g_signal_connect_object(self->node, "invalidated",
-                                G_CALLBACK(invalidated_event),
-                                self, 0);
+        self->computed_id = g_signal_connect_object(self->node, "computed",
+                                                    G_CALLBACK(computed_event),
+                                                    self, 0);
+        self->invalidated_id = g_signal_connect_object(self->node, "invalidated",
+                                                       G_CALLBACK(invalidated_event),
+                                                       self, 0);
 
         if (self->processor)
             g_object_unref(self->processor);
@@ -357,8 +360,11 @@ view_helper_set_node(ViewHelper *self, GeglNode *node)
         update_autoscale(self);
         trigger_processing(self, bbox);
 
-    } else
+    } else {
         self->node = NULL;
+        self->computed_id = 0;
+        self->invalidated_id = 0;
+    }
 }
 
 GeglNode *
diff --git a/gegl-gtk/internal/view-helper.h b/gegl-gtk/internal/view-helper.h
index 022ac5e..5285430 100644
--- a/gegl-gtk/internal/view-helper.h
+++ b/gegl-gtk/internal/view-helper.h
@@ -54,6 +54,9 @@ struct _ViewHelper {
     GeglRectangle *currently_processed_rect;
 
     GdkRectangle   widget_allocation; /* The allocated size of the widget */
+
+    gulong computed_id;
+    gulong invalidated_id;
 };
 
 struct _ViewHelperClass {


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