[gimp] app: clean up how tools are COMMITed and HALTed



commit ef294f4a541601862a5dcbf92212128444d2cd90
Author: Michael Natterer <mitch gimp org>
Date:   Sun Jul 9 16:22:18 2017 +0200

    app: clean up how tools are COMMITed and HALTed
    
    Call HALT generically in gimp_tool_control() after calling COMMIT, and
    remove all hacks in tools that call both COMMIT and HALT or call
    halt() from commit().
    
    Some tools interact with their subclasses (e.g. filter tool and
    operation tool), and it's essential that COMMIT runs through the
    entire class hierarchy before HALT.
    
    Probably breaks something, please test.

 app/tools/gimpblendtool.c             |    2 --
 app/tools/gimpcagetool.c              |    1 -
 app/tools/gimpcroptool.c              |    2 --
 app/tools/gimpfiltertool.c            |    2 --
 app/tools/gimpfreeselecttool.c        |   25 +++++++++++++++----------
 app/tools/gimpiscissorstool.c         |    2 --
 app/tools/gimpnpointdeformationtool.c |    1 -
 app/tools/gimprectangleselecttool.c   |    2 --
 app/tools/gimptool.c                  |    6 ++++++
 app/tools/gimptransformtool.c         |    1 -
 app/tools/gimpwarptool.c              |    7 ++-----
 11 files changed, 23 insertions(+), 28 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index c91b420..6c1e30c 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -717,8 +717,6 @@ gimp_blend_tool_commit (GimpBlendTool *blend_tool)
 
       gimp_image_flush (gimp_display_get_image (tool->display));
     }
-
-  gimp_blend_tool_halt (blend_tool);
 }
 
 static void
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 330c2e7..8d52119 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -605,7 +605,6 @@ gimp_cage_tool_key_press (GimpTool    *tool,
       else if (ct->tool_state == DEFORM_STATE_WAIT)
         {
           gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
-          gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
         }
       return TRUE;
 
diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c
index b5bad8d..7e45cc8 100644
--- a/app/tools/gimpcroptool.c
+++ b/app/tools/gimpcroptool.c
@@ -458,8 +458,6 @@ gimp_crop_tool_commit (GimpCropTool *crop_tool)
           gimp_image_flush (image);
         }
     }
-
-  gimp_crop_tool_halt (crop_tool);
 }
 
 static void
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 1265960..5d79088 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -1028,8 +1028,6 @@ gimp_filter_tool_commit (GimpFilterTool *filter_tool)
                                          config->filter_tool_max_recent);
         }
     }
-
-  gimp_filter_tool_halt (filter_tool);
 }
 
 static void
diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c
index 8924393..54bba55 100644
--- a/app/tools/gimpfreeselecttool.c
+++ b/app/tools/gimpfreeselecttool.c
@@ -216,6 +216,15 @@ gimp_free_select_tool_start (GimpFreeSelectTool *fst,
 }
 
 static void
+gimp_free_select_tool_halt (GimpFreeSelectTool *fst)
+{
+  GimpFreeSelectToolPrivate *private = fst->private;
+
+  gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (fst), NULL);
+  g_clear_object (&private->widget);
+}
+
+static void
 gimp_free_select_tool_commit (GimpFreeSelectTool *fst,
                               GimpDisplay        *display)
 {
@@ -240,15 +249,6 @@ gimp_free_select_tool_commit (GimpFreeSelectTool *fst,
 }
 
 static void
-gimp_free_select_tool_halt (GimpFreeSelectTool *fst)
-{
-  GimpFreeSelectToolPrivate *private = fst->private;
-
-  gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (fst), NULL);
-  g_clear_object (&private->widget);
-}
-
-static void
 gimp_free_select_tool_control (GimpTool       *tool,
                                GimpToolAction  action,
                                GimpDisplay    *display)
@@ -515,7 +515,12 @@ gimp_free_select_tool_polygon_response (GimpToolWidget     *polygon,
   switch (response_id)
     {
     case GIMP_TOOL_WIDGET_RESPONSE_CONFIRM:
-      gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, tool->display);
+      /*  don't gimp_tool_control(COMMIT) here because we don't always
+       *  want to HALT the tool after committing because we have a
+       *  subclass, we do that in the default implementation of
+       *  select().
+       */
+      gimp_free_select_tool_commit (fst, tool->display);
       break;
 
     case GIMP_TOOL_WIDGET_RESPONSE_CANCEL:
diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c
index ab479e0..eafe7e2 100644
--- a/app/tools/gimpiscissorstool.c
+++ b/app/tools/gimpiscissorstool.c
@@ -486,7 +486,6 @@ gimp_iscissors_tool_button_press (GimpTool            *tool,
                                              iscissors->y))
         {
           gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
-          gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
         }
       else if (! iscissors->curve->closed)
         {
@@ -1093,7 +1092,6 @@ gimp_iscissors_tool_key_press (GimpTool    *tool,
       if (iscissors->curve->closed && iscissors->mask)
         {
           gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
-          gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
           return TRUE;
         }
       return FALSE;
diff --git a/app/tools/gimpnpointdeformationtool.c b/app/tools/gimpnpointdeformationtool.c
index 0471142..2711189 100644
--- a/app/tools/gimpnpointdeformationtool.c
+++ b/app/tools/gimpnpointdeformationtool.c
@@ -468,7 +468,6 @@ gimp_n_point_deformation_tool_key_press (GimpTool    *tool,
     case GDK_KEY_KP_Enter:
     case GDK_KEY_ISO_Enter:
       gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
-      gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
       break;
 
     case GDK_KEY_Escape:
diff --git a/app/tools/gimprectangleselecttool.c b/app/tools/gimprectangleselecttool.c
index 39ed936..ee3540a 100644
--- a/app/tools/gimprectangleselecttool.c
+++ b/app/tools/gimprectangleselecttool.c
@@ -818,8 +818,6 @@ gimp_rectangle_select_tool_commit (GimpRectangleSelectTool *rect_tool)
   /* Reset the automatic undo/redo mechanism */
   priv->undo = NULL;
   priv->redo = NULL;
-
-  gimp_rectangle_select_tool_halt (rect_tool);
 }
 
 static void
diff --git a/app/tools/gimptool.c b/app/tools/gimptool.c
index 96e717b..4500792 100644
--- a/app/tools/gimptool.c
+++ b/app/tools/gimptool.c
@@ -708,7 +708,13 @@ gimp_tool_control (GimpTool       *tool,
       break;
 
     case GIMP_TOOL_ACTION_COMMIT:
+      /*  always HALT after COMMIT here and not in each tool individually;
+       *  some tools interact with their subclasses (e.g. filter tool
+       *  and operation tool), and it's essential that COMMIT runs
+       *  through the entire class hierarchy before HALT
+       */
       GIMP_TOOL_GET_CLASS (tool)->control (tool, action, display);
+      GIMP_TOOL_GET_CLASS (tool)->control (tool, GIMP_TOOL_ACTION_HALT, display);
       break;
     }
 }
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 54b7590..e7c6595 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -1361,7 +1361,6 @@ gimp_transform_tool_response (GimpToolGui       *gui,
     case GTK_RESPONSE_OK:
       g_return_if_fail (display != NULL);
       gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
-      gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
      break;
 
     default:
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index 6d34b68..c23c67d 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -241,10 +241,7 @@ gimp_warp_tool_button_press (GimpTool            *tool,
   gint             off_x, off_y;
 
   if (tool->display && display != tool->display)
-    {
-      gimp_tool_pop_status (tool, tool->display);
-      gimp_warp_tool_halt (wt);
-    }
+    gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, tool->display);
 
   if (! tool->display)
     {
@@ -383,7 +380,7 @@ gimp_warp_tool_key_press (GimpTool    *tool,
     case GDK_KEY_KP_Enter:
     case GDK_KEY_ISO_Enter:
       gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
-      /* fall thru */
+      return TRUE;
 
     case GDK_KEY_Escape:
       gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);


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