[gegl] Remove all pads when attaching operations to nodes



commit da1e991e9ffc58c75bfe0b863f70f8bac2f3866b
Author: Danny Robson <danny blubinc net>
Date:   Sat Jun 5 18:11:17 2010 +1000

    Remove all pads when attaching operations to nodes
    
    Instead of removing just 'input', 'aux', and 'output' pads when an
    operation is added to a node, remove all pads that are present before
    calling attach.

 gegl/graph/gegl-node.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/gegl/graph/gegl-node.c b/gegl/graph/gegl-node.c
index 9e9185f..acc85d9 100644
--- a/gegl/graph/gegl-node.c
+++ b/gegl/graph/gegl-node.c
@@ -1242,6 +1242,7 @@ gegl_node_set_operation_object (GeglNode      *self,
     GSList   *output_c        = NULL;
     GeglNode *output          = NULL;
     gchar    *output_dest_pad = NULL;
+    GSList   *old_pads        = NULL;
     GeglNode *input           = NULL;
     GeglNode *aux             = NULL;
 
@@ -1270,19 +1271,17 @@ gegl_node_set_operation_object (GeglNode      *self,
     gegl_node_disconnect_sources (self);
     gegl_node_disconnect_sinks (self);
 
-    /* FIXME: handle this in a more generic way, but it is needed to allow
-     * the attach to work properly.
-     */
-
-    if (gegl_node_get_pad (self, "output"))
-      gegl_node_remove_pad (self, gegl_node_get_pad (self, "output"));
-    if (gegl_node_get_pad (self, "input"))
-      gegl_node_remove_pad (self, gegl_node_get_pad (self, "input"));
-    if (gegl_node_get_pad (self, "aux"))
-      gegl_node_remove_pad (self, gegl_node_get_pad (self, "aux"));
+    /* Delete all the pads from the previous operation */
+    while ((old_pads = gegl_node_get_pads (self)) != NULL) 
+      {
+        gegl_node_remove_pad (self, old_pads->data);
+      }
 
     gegl_operation_attach (operation, self);
 
+    /* FIXME: handle this in a more generic way, but it is needed to allow
+     * the attach to work properly.
+     */
     if (input)
       gegl_node_connect_from (self, "input", input, "output");
     if (aux)



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