[gimp] app: reset an item's "removed" state as it is added to its parent container



commit 96efc7ea1c7bcbfb0858074ffabeec5098101022
Author: Michael Natterer <mitch gimp org>
Date:   Sun Jan 30 19:36:27 2011 +0100

    app: reset an item's "removed" state as it is added to its parent container
    
    and not "manually" from the resp. undo functions.

 app/core/gimpchannelundo.c    |    2 --
 app/core/gimpimage.c          |    9 +++++++++
 app/core/gimpitemtree.c       |    4 ++++
 app/core/gimplayer.c          |    4 ++++
 app/core/gimplayermaskundo.c  |    2 --
 app/core/gimplayerundo.c      |    9 ---------
 app/vectors/gimpvectorsundo.c |    2 --
 7 files changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/app/core/gimpchannelundo.c b/app/core/gimpchannelundo.c
index 4eff783..9563c5d 100644
--- a/app/core/gimpchannelundo.c
+++ b/app/core/gimpchannelundo.c
@@ -210,7 +210,5 @@ gimp_channel_undo_pop (GimpUndo            *undo,
       gimp_image_add_channel (undo->image, channel,
                               channel_undo->prev_parent,
                               channel_undo->prev_position, FALSE);
-
-      GIMP_ITEM (channel)->removed = FALSE;
     }
 }
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 5b234f3..94361e7 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -3471,6 +3471,15 @@ gimp_image_add_layer (GimpImage *image,
   if (old_has_alpha != gimp_image_has_alpha (image))
     private->flush_accum.alpha_changed = TRUE;
 
+  if (gimp_layer_get_mask (layer))
+    {
+      GimpLayerMask *mask = gimp_layer_get_mask (layer);
+
+      /*  if the layer came from the undo stack, reset the mask's "removed" state  */
+      if (gimp_item_is_removed (GIMP_ITEM (mask)))
+        GIMP_ITEM (mask)->removed = FALSE;
+    }
+
   return TRUE;
 }
 
diff --git a/app/core/gimpitemtree.c b/app/core/gimpitemtree.c
index 89be882..a74b9de 100644
--- a/app/core/gimpitemtree.c
+++ b/app/core/gimpitemtree.c
@@ -446,6 +446,10 @@ gimp_item_tree_add_item (GimpItemTree *tree,
                               GIMP_VIEWABLE (parent));
 
   gimp_container_insert (container, GIMP_OBJECT (item), position);
+
+  /*  if the item came from the undo stack, reset its "removed" state  */
+  if (gimp_item_is_removed (item))
+    item->removed = FALSE;
 }
 
 GimpItem *
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 0ddc338..c90b25f 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -1460,6 +1460,10 @@ gimp_layer_add_mask (GimpLayer      *layer,
 
   g_object_notify (G_OBJECT (layer), "mask");
 
+  /*  if the mask came from the undo stack, reset its "removed" state  */
+  if (gimp_item_is_removed (GIMP_ITEM (mask)))
+    GIMP_ITEM (mask)->removed = FALSE;
+
   return layer->mask;
 }
 
diff --git a/app/core/gimplayermaskundo.c b/app/core/gimplayermaskundo.c
index df88c45..5ecb009 100644
--- a/app/core/gimplayermaskundo.c
+++ b/app/core/gimplayermaskundo.c
@@ -180,8 +180,6 @@ gimp_layer_mask_undo_pop (GimpUndo            *undo,
       /*  restore layer mask  */
 
       gimp_layer_add_mask (layer, layer_mask_undo->layer_mask, FALSE, NULL);
-
-      GIMP_ITEM (layer_mask_undo->layer_mask)->removed = FALSE;
     }
 }
 
diff --git a/app/core/gimplayerundo.c b/app/core/gimplayerundo.c
index 3525d88..8dec92b 100644
--- a/app/core/gimplayerundo.c
+++ b/app/core/gimplayerundo.c
@@ -208,14 +208,5 @@ gimp_layer_undo_pop (GimpUndo            *undo,
       gimp_image_add_layer (undo->image, layer,
                             layer_undo->prev_parent,
                             layer_undo->prev_position, FALSE);
-
-      GIMP_ITEM (layer)->removed = FALSE;
-
-      if (gimp_layer_get_mask (layer))
-        {
-          GimpLayerMask *mask = gimp_layer_get_mask (layer);
-
-          GIMP_ITEM (mask)->removed = FALSE;
-        }
     }
 }
diff --git a/app/vectors/gimpvectorsundo.c b/app/vectors/gimpvectorsundo.c
index 7294721..4de9ae9 100644
--- a/app/vectors/gimpvectorsundo.c
+++ b/app/vectors/gimpvectorsundo.c
@@ -209,7 +209,5 @@ gimp_vectors_undo_pop (GimpUndo            *undo,
       gimp_image_add_vectors (undo->image, vectors,
                               vectors_undo->prev_parent,
                               vectors_undo->prev_position, FALSE);
-
-      GIMP_ITEM (vectors)->removed = FALSE;
     }
 }



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