[gnome-photos/wip/rishi/edit-mode: 3/30] gegl-gtk-view-helper: Disconnect signal handler when replacing node



commit fe7e0167a45c40c6ba30527ab03f0b13860c0854
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Jun 14 19:49:23 2015 +0200

    gegl-gtk-view-helper: Disconnect signal handler when replacing node
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750943

 src/gegl-gtk-view-helper.c |   14 +++++++++-----
 src/gegl-gtk-view-helper.h |    2 ++
 2 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/gegl-gtk-view-helper.c b/src/gegl-gtk-view-helper.c
index e8c1881..225bd8e 100644
--- a/src/gegl-gtk-view-helper.c
+++ b/src/gegl-gtk-view-helper.c
@@ -236,21 +236,25 @@ 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_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);
+        self->computed_id = g_signal_connect_object(self->node, "computed",
+                                                    G_CALLBACK(computed_event),
+                                                    self, 0);
 
         update_autoscale(self);
 
-    } else
+    } else {
         self->node = NULL;
+        self->computed_id = 0;
+    }
 }
 
 GeglNode *
diff --git a/src/gegl-gtk-view-helper.h b/src/gegl-gtk-view-helper.h
index fcf0e00..7bbc029 100644
--- a/src/gegl-gtk-view-helper.h
+++ b/src/gegl-gtk-view-helper.h
@@ -49,6 +49,8 @@ struct _ViewHelper {
     GeglGtkViewAutoscale autoscale_policy;
 
     GdkRectangle   widget_allocation; /* The allocated size of the widget */
+
+    gulong computed_id;
 };
 
 struct _ViewHelperClass {


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