[gegl] bin: only remove incoming edges if they are "clones"



commit dbf98a126e5de51df5b599cef6b24549a33f4176
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Jan 20 20:15:13 2019 +0100

    bin: only remove incoming edges if they are "clones"
    
    This avoids having very destructive actions that suddenly drop many nodes as a
    side effect.

 bin/ui.c | 47 ++++++++++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/bin/ui.c b/bin/ui.c
index ccef50de5..e1081f139 100644
--- a/bin/ui.c
+++ b/bin/ui.c
@@ -2885,22 +2885,39 @@ int cmd_remove (COMMAND_ARGS) /* "remove", 0, "", "removes active node"*/
   GeglNode *next, *prev;
 
   const gchar *consumer_name = NULL;
-  prev = gegl_node_get_producer (node, "input", NULL);
-  next = gegl_node_get_ui_consumer (node, "output", &consumer_name);
 
-  if (next && prev)
-    {
-      gegl_node_disconnect (node, "input");
-      gegl_node_connect_to (prev, "output", next, consumer_name);
-      gegl_node_remove_child (o->gegl, node);
-      o->active = prev;
-    }
-  else if (next)
-    {
-      gegl_node_disconnect (next, consumer_name);
-      gegl_node_remove_child (o->gegl, node);
-      o->active = next;
-    }
+
+  switch (o->pad_active)
+  {
+    case 0:
+      prev = gegl_node_get_producer (node, "input", NULL);
+      if (gegl_node_get_ui_consumer (prev, "output", NULL) != node)
+        gegl_node_disconnect (node, "input");
+      break;
+    case 1:
+      prev = gegl_node_get_producer (node, "aux", NULL);
+      if (gegl_node_get_ui_consumer (prev, "output", NULL) != node)
+        gegl_node_disconnect (node, "aux");
+      break;
+    case 2:
+      prev = gegl_node_get_producer (node, "input", NULL);
+      next = gegl_node_get_ui_consumer (node, "output", &consumer_name);
+
+      if (next && prev)
+      {
+        gegl_node_disconnect (node, "input");
+        gegl_node_connect_to (prev, "output", next, consumer_name);
+        gegl_node_remove_child (o->gegl, node);
+        o->active = prev;
+      }
+      else if (next)
+      {
+        gegl_node_disconnect (next, consumer_name);
+        gegl_node_remove_child (o->gegl, node);
+        o->active = next;
+      }
+    break;
+  }
 
   mrg_queue_draw (o->mrg, NULL);
   renderer_dirty++;


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