[gimp] Bug 795410 - Deleting a layer group and then undoing the deletion ...



commit 37742a9fee417985ebf195beefc5a05fd8c435a9
Author: Ell <ell_se yahoo com>
Date:   Sun Apr 22 03:39:40 2018 -0400

    Bug 795410 - Deleting a layer group and then undoing the deletion ...
    
    ... raises a CRITICAL
    
    gimp_item_{start,end}_move() currently serves two different
    purposes:  It is used by GimpLayer to suspend/resume mask resizing
    of the layer's ancestors; this is necessary whenever an operation
    on a layer might affect the size of its ancestors.  It is also used
    by GimpGroupLayer to suspend/resume its own mask resizing; this, on
    the other hand, is only necessary before applying one of the
    transformation functions to the group, so that mask modification is
    handled by GimpLayer.  In other words, the effects of
    gimp_item_{start,end}_move() on group layers are only necessary in
    a subset of the cases in which these functions are used.
    
    While in itself this isn't a problem, it does cause issues when
    removing a group layer:  gimp_image_remove_layer() calls
    gimp_item_start_move() before removing the layer, and
    gimp_item_end_move() afterwards.  While the former function is
    called while the layer is still attached to the image, the latter
    function is called after the layer is no longer attached.  Since
    GimpGroupLayer pushes an undo step in response to these calls, only
    the call to start_move() results in an undo step, while the call to
    end_move() doesn't, resulting in an unbalanced
    GIMP_UNDO_GROUP_LAYER_START_MOVE undo step on the stack.  This
    causes problems when undoing the operation.
    
    Add gimp_item_{start,end}_transform() functions, and corresponding
    GimpItem::{start,end}_transform() virtual functions, which are more
    specialized versions of gimp_item_{start,end}_move(), which should
    be used instead of the former before/after transforming an item; in
    other cases, such as when removing ot reordering an item,
    gimp_item_{start,end}_move() should still be used.  The default
    implementation of GimpItem::{start,end}_transform() calls
    gimp_item_{start,end}_move(), respectively, so subclasses that
    override these functions don't have to do that themselves.
    
    In GimpGroupLayer, override GimpItem::{start,end}_transform(),
    instead of GimpItem::{start,end}_move(), for the same purpose of
    suspending mask resize.  This avoids these functions from being
    called when removing a layer group, fixing the bug.

 app/core/core-enums.c          |    8 ++--
 app/core/core-enums.h          |    4 +-
 app/core/gimpgrouplayer.c      |   66 +++++++++++++++++--------------------
 app/core/gimpgrouplayer.h      |    4 +-
 app/core/gimpgrouplayerundo.c  |   20 ++++++------
 app/core/gimpimage-item-list.c |   16 ++++----
 app/core/gimpimage-resize.c    |    4 ++
 app/core/gimpimage-undo-push.c |   16 ++++----
 app/core/gimpimage-undo-push.h |    4 +-
 app/core/gimpitem.c            |   70 ++++++++++++++++++++++++++++++++++------
 app/core/gimpitem.h            |    9 +++++
 11 files changed, 140 insertions(+), 81 deletions(-)
---
diff --git a/app/core/core-enums.c b/app/core/core-enums.c
index 355b298..ce5781d 100644
--- a/app/core/core-enums.c
+++ b/app/core/core-enums.c
@@ -831,8 +831,8 @@ gimp_undo_type_get_type (void)
     { GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE, "GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE", 
"group-layer-resume-resize" },
     { GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK, "GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK", "group-layer-suspend-mask" },
     { GIMP_UNDO_GROUP_LAYER_RESUME_MASK, "GIMP_UNDO_GROUP_LAYER_RESUME_MASK", "group-layer-resume-mask" },
-    { GIMP_UNDO_GROUP_LAYER_START_MOVE, "GIMP_UNDO_GROUP_LAYER_START_MOVE", "group-layer-start-move" },
-    { GIMP_UNDO_GROUP_LAYER_END_MOVE, "GIMP_UNDO_GROUP_LAYER_END_MOVE", "group-layer-end-move" },
+    { GIMP_UNDO_GROUP_LAYER_START_TRANSFORM, "GIMP_UNDO_GROUP_LAYER_START_TRANSFORM", 
"group-layer-start-transform" },
+    { GIMP_UNDO_GROUP_LAYER_END_TRANSFORM, "GIMP_UNDO_GROUP_LAYER_END_TRANSFORM", 
"group-layer-end-transform" },
     { GIMP_UNDO_GROUP_LAYER_CONVERT, "GIMP_UNDO_GROUP_LAYER_CONVERT", "group-layer-convert" },
     { GIMP_UNDO_TEXT_LAYER, "GIMP_UNDO_TEXT_LAYER", "text-layer" },
     { GIMP_UNDO_TEXT_LAYER_MODIFIED, "GIMP_UNDO_TEXT_LAYER_MODIFIED", "text-layer-modified" },
@@ -929,8 +929,8 @@ gimp_undo_type_get_type (void)
     { GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE, NC_("undo-type", "Resume group layer resize"), NULL },
     { GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK, NC_("undo-type", "Suspend group layer mask"), NULL },
     { GIMP_UNDO_GROUP_LAYER_RESUME_MASK, NC_("undo-type", "Resume group layer mask"), NULL },
-    { GIMP_UNDO_GROUP_LAYER_START_MOVE, NC_("undo-type", "Start moving group layer"), NULL },
-    { GIMP_UNDO_GROUP_LAYER_END_MOVE, NC_("undo-type", "End moving group layer"), NULL },
+    { GIMP_UNDO_GROUP_LAYER_START_TRANSFORM, NC_("undo-type", "Start transforming group layer"), NULL },
+    { GIMP_UNDO_GROUP_LAYER_END_TRANSFORM, NC_("undo-type", "End transforming group layer"), NULL },
     { GIMP_UNDO_GROUP_LAYER_CONVERT, NC_("undo-type", "Convert group layer"), NULL },
     { GIMP_UNDO_TEXT_LAYER, NC_("undo-type", "Text layer"), NULL },
     { GIMP_UNDO_TEXT_LAYER_MODIFIED, NC_("undo-type", "Text layer modification"), NULL },
diff --git a/app/core/core-enums.h b/app/core/core-enums.h
index 7cafdf3..76fef44 100644
--- a/app/core/core-enums.h
+++ b/app/core/core-enums.h
@@ -427,8 +427,8 @@ typedef enum /*< pdb-skip >*/
   GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE,/*< desc="Resume group layer resize"   >*/
   GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK, /*< desc="Suspend group layer mask"    >*/
   GIMP_UNDO_GROUP_LAYER_RESUME_MASK,  /*< desc="Resume group layer mask"     >*/
-  GIMP_UNDO_GROUP_LAYER_START_MOVE,   /*< desc="Start moving group layer"    >*/
-  GIMP_UNDO_GROUP_LAYER_END_MOVE,     /*< desc="End moving group layer"      >*/
+  GIMP_UNDO_GROUP_LAYER_START_TRANSFORM,/*< desc="Start transforming group layer" >*/
+  GIMP_UNDO_GROUP_LAYER_END_TRANSFORM,/*< desc="End transforming group layer">*/
   GIMP_UNDO_GROUP_LAYER_CONVERT,      /*< desc="Convert group layer"         >*/
   GIMP_UNDO_TEXT_LAYER,               /*< desc="Text layer"                  >*/
   GIMP_UNDO_TEXT_LAYER_MODIFIED,      /*< desc="Text layer modification"     >*/
diff --git a/app/core/gimpgrouplayer.c b/app/core/gimpgrouplayer.c
index 327086a..e7612fa 100644
--- a/app/core/gimpgrouplayer.c
+++ b/app/core/gimpgrouplayer.c
@@ -61,7 +61,7 @@ struct _GimpGroupLayerPrivate
   gint            suspend_mask;
   GeglBuffer     *suspended_mask_buffer;
   GeglRectangle   suspended_mask_bounds;
-  gint            moving;
+  gint            transforming;
   gboolean        expanded;
   gboolean        pass_through;
 
@@ -108,9 +108,9 @@ static GimpItem      * gimp_group_layer_duplicate    (GimpItem        *item,
 static void            gimp_group_layer_convert      (GimpItem        *item,
                                                       GimpImage       *dest_image,
                                                       GType            old_type);
-static void            gimp_group_layer_start_move   (GimpItem        *item,
+static void         gimp_group_layer_start_transform (GimpItem        *item,
                                                       gboolean         push_undo);
-static void            gimp_group_layer_end_move     (GimpItem        *item,
+static void           gimp_group_layer_end_transform (GimpItem        *item,
                                                       gboolean         push_undo);
 static void            gimp_group_layer_resize       (GimpItem        *item,
                                                       GimpContext     *context,
@@ -270,8 +270,8 @@ gimp_group_layer_class_init (GimpGroupLayerClass *klass)
   item_class->is_position_locked         = gimp_group_layer_is_position_locked;
   item_class->duplicate                  = gimp_group_layer_duplicate;
   item_class->convert                    = gimp_group_layer_convert;
-  item_class->start_move                 = gimp_group_layer_start_move;
-  item_class->end_move                   = gimp_group_layer_end_move;
+  item_class->start_transform            = gimp_group_layer_start_transform;
+  item_class->end_transform              = gimp_group_layer_end_transform;
   item_class->resize                     = gimp_group_layer_resize;
 
   item_class->default_name               = _("Layer Group");
@@ -606,23 +606,23 @@ gimp_group_layer_convert (GimpItem  *item,
 }
 
 static void
-gimp_group_layer_start_move (GimpItem *item,
+gimp_group_layer_start_transform (GimpItem *item,
                              gboolean  push_undo)
 {
-  _gimp_group_layer_start_move (GIMP_GROUP_LAYER (item), push_undo);
+  _gimp_group_layer_start_transform (GIMP_GROUP_LAYER (item), push_undo);
 
-  if (GIMP_ITEM_CLASS (parent_class)->start_move)
-    GIMP_ITEM_CLASS (parent_class)->start_move (item, push_undo);
+  if (GIMP_ITEM_CLASS (parent_class)->start_transform)
+    GIMP_ITEM_CLASS (parent_class)->start_transform (item, push_undo);
 }
 
 static void
-gimp_group_layer_end_move (GimpItem *item,
+gimp_group_layer_end_transform (GimpItem *item,
                            gboolean  push_undo)
 {
-  if (GIMP_ITEM_CLASS (parent_class)->end_move)
-    GIMP_ITEM_CLASS (parent_class)->end_move (item, push_undo);
+  if (GIMP_ITEM_CLASS (parent_class)->end_transform)
+    GIMP_ITEM_CLASS (parent_class)->end_transform (item, push_undo);
 
-  _gimp_group_layer_end_move (GIMP_GROUP_LAYER (item), push_undo);
+  _gimp_group_layer_end_transform (GIMP_GROUP_LAYER (item), push_undo);
 }
 
 static void
@@ -640,12 +640,10 @@ gimp_group_layer_resize (GimpItem     *item,
   gint                   x, y;
 
   /* we implement GimpItem::resize(), instead of GimpLayer::resize(), so that
-   * GimpLayer doesn't resize the mask.  instead, we temporarily decrement
-   * private->moving, so that mask resizing is handled by
-   * gimp_group_layer_update_size().
+   * GimpLayer doesn't resize the mask.  note that gimp_item_resize() calls
+   * gimp_item_{start,end}_move(), and not gimp_item_{start,end}_transform(),
+   * so that mask resizing is handled by gimp_group_layer_update_size().
    */
-  g_return_if_fail (private->moving > 0);
-  private->moving--;
 
   x = gimp_item_get_offset_x (item) - offset_x;
   y = gimp_item_get_offset_y (item) - offset_y;
@@ -697,8 +695,6 @@ gimp_group_layer_resize (GimpItem     *item,
     }
 
   gimp_group_layer_resume_resize (group, TRUE);
-
-  private->moving++;
 }
 
 static gint64
@@ -1631,8 +1627,8 @@ _gimp_group_layer_get_suspended_mask (GimpGroupLayer *group,
 }
 
 void
-_gimp_group_layer_start_move (GimpGroupLayer *group,
-                              gboolean        push_undo)
+_gimp_group_layer_start_transform (GimpGroupLayer *group,
+                                   gboolean        push_undo)
 {
   GimpGroupLayerPrivate *private;
   GimpItem              *item;
@@ -1648,15 +1644,15 @@ _gimp_group_layer_start_move (GimpGroupLayer *group,
     push_undo = FALSE;
 
   if (push_undo)
-    gimp_image_undo_push_group_layer_start_move (gimp_item_get_image (item),
-                                                 NULL, group);
+    gimp_image_undo_push_group_layer_start_transform (gimp_item_get_image (item),
+                                                      NULL, group);
 
-  private->moving++;
+  private->transforming++;
 }
 
 void
-_gimp_group_layer_end_move (GimpGroupLayer *group,
-                            gboolean        push_undo)
+_gimp_group_layer_end_transform (GimpGroupLayer *group,
+                                 gboolean        push_undo)
 {
   GimpGroupLayerPrivate *private;
   GimpItem              *item;
@@ -1667,18 +1663,18 @@ _gimp_group_layer_end_move (GimpGroupLayer *group,
   item    = GIMP_ITEM (group);
 
   g_return_if_fail (private->suspend_mask == 0);
-  g_return_if_fail (private->moving > 0);
+  g_return_if_fail (private->transforming > 0);
 
   if (! gimp_item_is_attached (item))
     push_undo = FALSE;
 
   if (push_undo)
-    gimp_image_undo_push_group_layer_end_move (gimp_item_get_image (item),
-                                               NULL, group);
+    gimp_image_undo_push_group_layer_end_transform (gimp_item_get_image (item),
+                                                    NULL, group);
 
-  private->moving--;
+  private->transforming--;
 
-  if (private->moving == 0)
+  if (private->transforming == 0)
     gimp_group_layer_update_mask_size (GIMP_GROUP_LAYER (item));
 }
 
@@ -1926,10 +1922,10 @@ gimp_group_layer_update_size (GimpGroupLayer *group)
         }
     }
 
-  /* resize the mask if not moving (in which case, GimpLayer takes care of the
-   * mask)
+  /* resize the mask if not transforming (in which case, GimpLayer takes care
+   * of the mask)
    */
-  if (resize_mask && ! private->moving)
+  if (resize_mask && ! private->transforming)
     gimp_group_layer_update_mask_size (group);
 
   /* if we show the mask, invalidate the new mask area */
diff --git a/app/core/gimpgrouplayer.h b/app/core/gimpgrouplayer.h
index 8a0a6c1..8978103 100644
--- a/app/core/gimpgrouplayer.h
+++ b/app/core/gimpgrouplayer.h
@@ -69,9 +69,9 @@ void             _gimp_group_layer_set_suspended_mask (GimpGroupLayer      *grou
 GeglBuffer     * _gimp_group_layer_get_suspended_mask (GimpGroupLayer      *group,
                                                        GeglRectangle       *bounds);
 
-void             _gimp_group_layer_start_move         (GimpGroupLayer      *group,
+void             _gimp_group_layer_start_transform    (GimpGroupLayer      *group,
                                                        gboolean             push_undo);
-void             _gimp_group_layer_end_move           (GimpGroupLayer      *group,
+void             _gimp_group_layer_end_transform      (GimpGroupLayer      *group,
                                                        gboolean             push_undo);
 
 
diff --git a/app/core/gimpgrouplayerundo.c b/app/core/gimpgrouplayerundo.c
index cef6c29..040bf73 100644
--- a/app/core/gimpgrouplayerundo.c
+++ b/app/core/gimpgrouplayerundo.c
@@ -82,8 +82,8 @@ gimp_group_layer_undo_constructed (GObject *object)
     case GIMP_UNDO_GROUP_LAYER_SUSPEND_RESIZE:
     case GIMP_UNDO_GROUP_LAYER_RESUME_RESIZE:
     case GIMP_UNDO_GROUP_LAYER_SUSPEND_MASK:
-    case GIMP_UNDO_GROUP_LAYER_START_MOVE:
-    case GIMP_UNDO_GROUP_LAYER_END_MOVE:
+    case GIMP_UNDO_GROUP_LAYER_START_TRANSFORM:
+    case GIMP_UNDO_GROUP_LAYER_END_TRANSFORM:
       break;
 
     case GIMP_UNDO_GROUP_LAYER_RESUME_MASK:
@@ -192,22 +192,22 @@ gimp_group_layer_undo_pop (GimpUndo            *undo,
         }
       break;
 
-    case GIMP_UNDO_GROUP_LAYER_START_MOVE:
-    case GIMP_UNDO_GROUP_LAYER_END_MOVE:
+    case GIMP_UNDO_GROUP_LAYER_START_TRANSFORM:
+    case GIMP_UNDO_GROUP_LAYER_END_TRANSFORM:
       if ((undo_mode       == GIMP_UNDO_MODE_UNDO &&
-           undo->undo_type == GIMP_UNDO_GROUP_LAYER_START_MOVE) ||
+           undo->undo_type == GIMP_UNDO_GROUP_LAYER_START_TRANSFORM) ||
           (undo_mode       == GIMP_UNDO_MODE_REDO &&
-           undo->undo_type == GIMP_UNDO_GROUP_LAYER_END_MOVE))
+           undo->undo_type == GIMP_UNDO_GROUP_LAYER_END_TRANSFORM))
         {
-          /*  end group layer move operation  */
+          /*  end group layer transform operation  */
 
-          _gimp_group_layer_end_move (group, FALSE);
+          _gimp_group_layer_end_transform (group, FALSE);
         }
       else
         {
-          /*  start group layer move operation  */
+          /*  start group layer transform operation  */
 
-          _gimp_group_layer_start_move (group, FALSE);
+          _gimp_group_layer_start_transform (group, FALSE);
         }
       break;
 
diff --git a/app/core/gimpimage-item-list.c b/app/core/gimpimage-item-list.c
index 4f08e13..1fb42b8 100644
--- a/app/core/gimpimage-item-list.c
+++ b/app/core/gimpimage-item-list.c
@@ -118,7 +118,7 @@ gimp_image_item_list_translate (GimpImage *image,
             }
 
           for (l = list; l; l = g_list_next (l))
-            gimp_item_start_move (GIMP_ITEM (l->data), push_undo);
+            gimp_item_start_transform (GIMP_ITEM (l->data), push_undo);
         }
 
       for (l = list; l; l = g_list_next (l))
@@ -128,7 +128,7 @@ gimp_image_item_list_translate (GimpImage *image,
       if (list->next)
         {
           for (l = list; l; l = g_list_next (l))
-            gimp_item_end_move (GIMP_ITEM (l->data), push_undo);
+            gimp_item_end_transform (GIMP_ITEM (l->data), push_undo);
 
           if (push_undo)
             gimp_image_undo_group_end (image);
@@ -157,7 +157,7 @@ gimp_image_item_list_flip (GimpImage           *image,
                                        C_("undo-type", "Flip Items"));
 
           for (l = list; l; l = g_list_next (l))
-            gimp_item_start_move (GIMP_ITEM (l->data), TRUE);
+            gimp_item_start_transform (GIMP_ITEM (l->data), TRUE);
         }
 
       for (l = list; l; l = g_list_next (l))
@@ -167,7 +167,7 @@ gimp_image_item_list_flip (GimpImage           *image,
       if (list->next)
         {
           for (l = list; l; l = g_list_next (l))
-            gimp_item_end_move (GIMP_ITEM (l->data), TRUE);
+            gimp_item_end_transform (GIMP_ITEM (l->data), TRUE);
 
           gimp_image_undo_group_end (image);
         }
@@ -196,7 +196,7 @@ gimp_image_item_list_rotate (GimpImage        *image,
                                        C_("undo-type", "Rotate Items"));
 
           for (l = list; l; l = g_list_next (l))
-            gimp_item_start_move (GIMP_ITEM (l->data), TRUE);
+            gimp_item_start_transform (GIMP_ITEM (l->data), TRUE);
         }
 
       for (l = list; l; l = g_list_next (l))
@@ -206,7 +206,7 @@ gimp_image_item_list_rotate (GimpImage        *image,
       if (list->next)
         {
           for (l = list; l; l = g_list_next (l))
-            gimp_item_end_move (GIMP_ITEM (l->data), TRUE);
+            gimp_item_end_transform (GIMP_ITEM (l->data), TRUE);
 
           gimp_image_undo_group_end (image);
         }
@@ -246,7 +246,7 @@ gimp_image_item_list_transform (GimpImage              *image,
                                        C_("undo-type", "Transform Items"));
 
           for (l = list; l; l = g_list_next (l))
-            gimp_item_start_move (GIMP_ITEM (l->data), TRUE);
+            gimp_item_start_transform (GIMP_ITEM (l->data), TRUE);
         }
 
       for (l = list; l; l = g_list_next (l))
@@ -263,7 +263,7 @@ gimp_image_item_list_transform (GimpImage              *image,
       if (list->next)
         {
           for (l = list; l; l = g_list_next (l))
-            gimp_item_end_move (GIMP_ITEM (l->data), TRUE);
+            gimp_item_end_transform (GIMP_ITEM (l->data), TRUE);
 
           gimp_image_undo_group_end (image);
         }
diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c
index 64b0a06..9d692ca 100644
--- a/app/core/gimpimage-resize.c
+++ b/app/core/gimpimage-resize.c
@@ -132,6 +132,10 @@ gimp_image_resize_with_layers (GimpImage    *image,
       if (! resize_text_layers && gimp_item_is_text_layer (item))
         continue;
 
+      /* note that we call gimp_item_start_move(), and not
+       * gimp_item_start_transform().  see the comment in gimp_item_resize()
+       * for more information.
+       */
       gimp_item_start_move (item, TRUE);
 
       gimp_object_queue_push (queue, item);
diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c
index 4eae6ef..53ab66b 100644
--- a/app/core/gimpimage-undo-push.c
+++ b/app/core/gimpimage-undo-push.c
@@ -672,32 +672,32 @@ gimp_image_undo_push_group_layer_resume_mask (GimpImage      *image,
 }
 
 GimpUndo *
-gimp_image_undo_push_group_layer_start_move (GimpImage      *image,
-                                             const gchar    *undo_desc,
-                                             GimpGroupLayer *group)
+gimp_image_undo_push_group_layer_start_transform (GimpImage      *image,
+                                                  const gchar    *undo_desc,
+                                                  GimpGroupLayer *group)
 {
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
   g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
   g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
 
   return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
-                               GIMP_UNDO_GROUP_LAYER_START_MOVE, undo_desc,
+                               GIMP_UNDO_GROUP_LAYER_START_TRANSFORM, undo_desc,
                                GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
                                "item",  group,
                                NULL);
 }
 
 GimpUndo *
-gimp_image_undo_push_group_layer_end_move (GimpImage      *image,
-                                           const gchar    *undo_desc,
-                                           GimpGroupLayer *group)
+gimp_image_undo_push_group_layer_end_transform (GimpImage      *image,
+                                                const gchar    *undo_desc,
+                                                GimpGroupLayer *group)
 {
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
   g_return_val_if_fail (GIMP_IS_GROUP_LAYER (group), NULL);
   g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (group)), NULL);
 
   return gimp_image_undo_push (image, GIMP_TYPE_GROUP_LAYER_UNDO,
-                               GIMP_UNDO_GROUP_LAYER_END_MOVE, undo_desc,
+                               GIMP_UNDO_GROUP_LAYER_END_TRANSFORM, undo_desc,
                                GIMP_DIRTY_ITEM | GIMP_DIRTY_DRAWABLE,
                                "item",  group,
                                NULL);
diff --git a/app/core/gimpimage-undo-push.h b/app/core/gimpimage-undo-push.h
index d83398a..22071ff 100644
--- a/app/core/gimpimage-undo-push.h
+++ b/app/core/gimpimage-undo-push.h
@@ -162,11 +162,11 @@ GimpUndo *
                                                      const gchar    *undo_desc,
                                                      GimpGroupLayer *group);
 GimpUndo *
-      gimp_image_undo_push_group_layer_start_move   (GimpImage      *image,
+   gimp_image_undo_push_group_layer_start_transform (GimpImage      *image,
                                                      const gchar    *undo_desc,
                                                      GimpGroupLayer *group);
 GimpUndo *
-      gimp_image_undo_push_group_layer_end_move     (GimpImage      *image,
+     gimp_image_undo_push_group_layer_end_transform (GimpImage      *image,
                                                      const gchar    *undo_desc,
                                                      GimpGroupLayer *group);
 GimpUndo * gimp_image_undo_push_group_layer_convert (GimpImage      *image,
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 29dfbcc..c49327c 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -143,6 +143,10 @@ static gboolean   gimp_item_real_rename             (GimpItem       *item,
                                                      const gchar    *new_name,
                                                      const gchar    *undo_desc,
                                                      GError        **error);
+static void       gimp_item_real_start_transform    (GimpItem       *item,
+                                                     gboolean        push_undo);
+static void       gimp_item_real_end_transform      (GimpItem       *item,
+                                                     gboolean        push_undo);
 static void       gimp_item_real_translate          (GimpItem       *item,
                                                      gint            offset_x,
                                                      gint            offset_y,
@@ -261,6 +265,8 @@ gimp_item_class_init (GimpItemClass *klass)
   klass->rename                    = gimp_item_real_rename;
   klass->start_move                = NULL;
   klass->end_move                  = NULL;
+  klass->start_transform           = gimp_item_real_start_transform;
+  klass->end_transform             = gimp_item_real_end_transform;
   klass->translate                 = gimp_item_real_translate;
   klass->scale                     = gimp_item_real_scale;
   klass->resize                    = gimp_item_real_resize;
@@ -618,6 +624,20 @@ gimp_item_real_translate (GimpItem *item,
 }
 
 static void
+gimp_item_real_start_transform (GimpItem *item,
+                                gboolean  push_undo)
+{
+  gimp_item_start_move (item, push_undo);
+}
+
+static void
+gimp_item_real_end_transform (GimpItem *item,
+                                gboolean  push_undo)
+{
+  gimp_item_end_move (item, push_undo);
+}
+
+static void
 gimp_item_real_scale (GimpItem              *item,
                       gint                   new_width,
                       gint                   new_height,
@@ -1204,6 +1224,26 @@ gimp_item_end_move (GimpItem *item,
     GIMP_ITEM_GET_CLASS (item)->end_move (item, push_undo);
 }
 
+void
+gimp_item_start_transform (GimpItem *item,
+                           gboolean  push_undo)
+{
+  g_return_if_fail (GIMP_IS_ITEM (item));
+
+  if (GIMP_ITEM_GET_CLASS (item)->start_transform)
+    GIMP_ITEM_GET_CLASS (item)->start_transform (item, push_undo);
+}
+
+void
+gimp_item_end_transform (GimpItem *item,
+                         gboolean  push_undo)
+{
+  g_return_if_fail (GIMP_IS_ITEM (item));
+
+  if (GIMP_ITEM_GET_CLASS (item)->end_transform)
+    GIMP_ITEM_GET_CLASS (item)->end_transform (item, push_undo);
+}
+
 /**
  * gimp_item_translate:
  * @item:      The #GimpItem to move.
@@ -1235,11 +1275,11 @@ gimp_item_translate (GimpItem *item,
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_DISPLACE,
                                  item_class->translate_desc);
 
-  gimp_item_start_move (item, push_undo);
+  gimp_item_start_transform (item, push_undo);
 
   item_class->translate (item, offset_x, offset_y, push_undo);
 
-  gimp_item_end_move (item, push_undo);
+  gimp_item_end_transform (item, push_undo);
 
   if (push_undo)
     gimp_image_undo_group_end (image);
@@ -1319,7 +1359,7 @@ gimp_item_scale (GimpItem              *item,
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_SCALE,
                                  item_class->scale_desc);
 
-  gimp_item_start_move (item, push_undo);
+  gimp_item_start_transform (item, push_undo);
 
   g_object_freeze_notify (G_OBJECT (item));
 
@@ -1328,7 +1368,7 @@ gimp_item_scale (GimpItem              *item,
 
   g_object_thaw_notify (G_OBJECT (item));
 
-  gimp_item_end_move (item, push_undo);
+  gimp_item_end_transform (item, push_undo);
 
   if (push_undo)
     gimp_image_undo_group_end (image);
@@ -1547,6 +1587,16 @@ gimp_item_resize (GimpItem     *item,
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
                                  item_class->resize_desc);
 
+  /* note that we call gimp_item_start_move(), and not
+   * gimp_item_start_transform().  whether or not a resize operation should be
+   * considered a transform operation, or a move operation, depends on the
+   * intended use of these functions by subclasses.  atm, we only use
+   * gimp_item_{start,end}_transform() to suspend mask resizing in group
+   * layers, which should not happen when reisizing a group, hence the call to
+   * gimp_item_start_move().
+   *
+   * see the comment in gimp_group_layer_resize() for more information.
+   */
   gimp_item_start_move (item, push_undo);
 
   g_object_freeze_notify (G_OBJECT (item));
@@ -1586,7 +1636,7 @@ gimp_item_flip (GimpItem            *item,
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
                                  item_class->flip_desc);
 
-  gimp_item_start_move (item, push_undo);
+  gimp_item_start_transform (item, push_undo);
 
   g_object_freeze_notify (G_OBJECT (item));
 
@@ -1594,7 +1644,7 @@ gimp_item_flip (GimpItem            *item,
 
   g_object_thaw_notify (G_OBJECT (item));
 
-  gimp_item_end_move (item, push_undo);
+  gimp_item_end_transform (item, push_undo);
 
   if (push_undo)
     gimp_image_undo_group_end (image);
@@ -1625,7 +1675,7 @@ gimp_item_rotate (GimpItem         *item,
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
                                  item_class->rotate_desc);
 
-  gimp_item_start_move (item, push_undo);
+  gimp_item_start_transform (item, push_undo);
 
   g_object_freeze_notify (G_OBJECT (item));
 
@@ -1634,7 +1684,7 @@ gimp_item_rotate (GimpItem         *item,
 
   g_object_thaw_notify (G_OBJECT (item));
 
-  gimp_item_end_move (item, push_undo);
+  gimp_item_end_transform (item, push_undo);
 
   if (push_undo)
     gimp_image_undo_group_end (image);
@@ -1668,7 +1718,7 @@ gimp_item_transform (GimpItem               *item,
     gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
                                  item_class->transform_desc);
 
-  gimp_item_start_move (item, push_undo);
+  gimp_item_start_transform (item, push_undo);
 
   g_object_freeze_notify (G_OBJECT (item));
 
@@ -1677,7 +1727,7 @@ gimp_item_transform (GimpItem               *item,
 
   g_object_thaw_notify (G_OBJECT (item));
 
-  gimp_item_end_move (item, push_undo);
+  gimp_item_end_transform (item, push_undo);
 
   if (push_undo)
     gimp_image_undo_group_end (image);
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index 783d07a..efe1804 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -73,6 +73,10 @@ struct _GimpItemClass
                                           gboolean                push_undo);
   void            (* end_move)           (GimpItem               *item,
                                           gboolean                push_undo);
+  void            (* start_transform)    (GimpItem               *item,
+                                          gboolean                push_undo);
+  void            (* end_transform)      (GimpItem               *item,
+                                          gboolean                push_undo);
   void            (* translate)          (GimpItem               *item,
                                           gint                    offset_x,
                                           gint                    offset_y,
@@ -216,6 +220,11 @@ void            gimp_item_start_move         (GimpItem           *item,
 void            gimp_item_end_move           (GimpItem           *item,
                                               gboolean            push_undo);
 
+void            gimp_item_start_transform    (GimpItem           *item,
+                                              gboolean            push_undo);
+void            gimp_item_end_transform      (GimpItem           *item,
+                                              gboolean            push_undo);
+
 void            gimp_item_translate          (GimpItem           *item,
                                               gint                offset_x,
                                               gint                offset_y,


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