[gegl/wip/rishi/node-connect: 2/2] Short circuit gegl_node_connect_from if the nodes are already connected



commit b746c2d968efe9edc6c4756547c8a5948f3c90a3
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Mar 2 14:25:12 2016 +0100

    Short circuit gegl_node_connect_from if the nodes are already connected
    
    This avoids a needless invalidation when the parameters are already
    connected as desired.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762987

 gegl/graph/gegl-node.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index 99b5af2..bb767bb 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -724,10 +724,15 @@ gegl_node_connect_from (GeglNode    *sink,
 
   if (gegl_node_pads_exist (real_sink, real_sink_pad_name, real_source, real_source_pad_name))
     {
+      GeglPad        *other_pad;
       GeglPad        *sink_pad   = gegl_node_get_pad (real_sink, real_sink_pad_name);
       GeglPad        *source_pad = gegl_node_get_pad (real_source, real_source_pad_name);
       GeglConnection *connection;
 
+      other_pad = gegl_pad_get_connected_to (sink_pad);
+      if (sink_pad == other_pad)
+        return TRUE;
+
       gegl_node_disconnect (real_sink, real_sink_pad_name);
 
       connection = gegl_pad_connect (sink_pad, source_pad);


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