[gimp] Issue #2308 - Strange behavior when switching active layer during transform



commit 3eaae585957eb1f008a9c203f7ecd2daf256cec0
Author: Ell <ell_se yahoo com>
Date:   Thu Oct 4 21:46:10 2018 -0400

    Issue #2308 - Strange behavior when switching active layer during transform
    
    Replace GimpTransformTool's 'drawable' field with an 'item' field,
    and have GimpTransformGridTool set it to the active item, to which
    the transformation is applied, during its initialization.  In
    gimp_transform_tool_get_active_item(), return the value of the
    transform tool's 'item' field, if not NULL, instead of the image's
    active item.  This makes sure we apply that transform-grid tools
    apply the transformation for the item for which they were
    activated, even if the image's active item has changed.

 app/tools/gimptransformgridtool.c | 12 ++++++------
 app/tools/gimptransformtool.c     |  5 ++++-
 app/tools/gimptransformtool.h     |  2 +-
 3 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/app/tools/gimptransformgridtool.c b/app/tools/gimptransformgridtool.c
index 01d0d880f7..8f8c67c8ca 100644
--- a/app/tools/gimptransformgridtool.c
+++ b/app/tools/gimptransformgridtool.c
@@ -252,10 +252,10 @@ gimp_transform_grid_tool_initialize (GimpTool     *tool,
   if (! item)
     return FALSE;
 
-  tool->display     = display;
-  tool->drawable    = drawable;
+  tool->display  = display;
+  tool->drawable = drawable;
 
-  tr_tool->drawable = drawable;
+  tr_tool->item  = item;
 
   /*  Initialize the transform_grid tool dialog  */
   if (! tg_tool->gui)
@@ -873,10 +873,10 @@ gimp_transform_grid_tool_halt (GimpTransformGridTool *tg_tool)
 
   gimp_transform_grid_tool_show_active_item (tg_tool);
 
-  tool->display     = NULL;
-  tool->drawable    = NULL;
+  tool->display  = NULL;
+  tool->drawable = NULL;
 
-  tr_tool->drawable = NULL;
+  tr_tool->item  = NULL;
 }
 
 static void
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 95918c7692..5ce737e2ea 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -461,6 +461,9 @@ gimp_transform_tool_get_active_item (GimpTransformTool  *tr_tool,
 
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
 
+  if (tr_tool->item)
+    return tr_tool->item;
+
   switch (options->type)
     {
     case GIMP_TRANSFORM_TYPE_LAYER:
@@ -513,7 +516,7 @@ gimp_transform_tool_check_active_item (GimpTransformTool  *tr_tool,
             locked_message = _("The active layer's position and size are locked.");
 
           if (! gimp_item_is_visible (item) &&
-              GIMP_DRAWABLE (item) != tr_tool->drawable) /* see bug #759194 */
+              item != tr_tool->item) /* see bug #759194 */
             {
               g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
                                    _("The active layer is not visible."));
diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h
index 04664df164..fb6899a860 100644
--- a/app/tools/gimptransformtool.h
+++ b/app/tools/gimptransformtool.h
@@ -47,7 +47,7 @@ struct _GimpTransformTool
 {
   GimpDrawTool  parent_instance;
 
-  GimpDrawable *drawable;
+  GimpItem     *item;
 
   gint          x1, y1;             /*  upper left hand coordinate         */
   gint          x2, y2;             /*  lower right hand coords            */


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