[gimp] app: don't add GimpLayer's source node to two different parents



commit 208fedd7ea0a19ec3d356a082c9283030c2a0657
Author: Michael Natterer <mitch gimp org>
Date:   Fri Sep 23 21:58:00 2011 +0200

    app: don't add GimpLayer's source node to two different parents
    
    When the layer is a floating selection, its source node is being
    hijacked by the underlying drawable to be composited on top of it.
    This can happen before the layer's own layer node is being created; in
    this case we must not add the source node to the layer node. Detaching
    the floating selection in any way will fix up things later.

 app/core/gimplayer.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index aea711e..2771b88 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -809,11 +809,21 @@ gimp_layer_get_node (GimpItem *item)
   GeglNode     *offset_node;
   GeglNode     *source;
   GeglNode     *mode_node;
+  gboolean      source_node_hijacked = FALSE;
 
   node = GIMP_ITEM_CLASS (parent_class)->get_node (item);
 
   source = gimp_drawable_get_source_node (drawable);
-  gegl_node_add_child (node, source);
+
+  /* if the source node already has a parent, we are a floating
+   * selection and the source node has been hijacked by the fs'
+   * drawable
+   */
+  if (gegl_node_get_parent (source))
+    source_node_hijacked = TRUE;
+
+  if (! source_node_hijacked)
+    gegl_node_add_child (node, source);
 
   g_warn_if_fail (layer->opacity_node == NULL);
 
@@ -821,8 +831,10 @@ gimp_layer_get_node (GimpItem *item)
                                              "operation", "gegl:opacity",
                                              "value",     layer->opacity,
                                              NULL);
-  gegl_node_connect_to (source,              "output",
-                        layer->opacity_node, "input");
+
+  if (! source_node_hijacked)
+    gegl_node_connect_to (source,              "output",
+                          layer->opacity_node, "input");
 
   if (layer->mask)
     {



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