Commit ef294f4a authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent 3fd21865
......@@ -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
......
......@@ -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;
......
......@@ -458,8 +458,6 @@ gimp_crop_tool_commit (GimpCropTool *crop_tool)
gimp_image_flush (image);
}
}
gimp_crop_tool_halt (crop_tool);
}
static void
......
......@@ -1028,8 +1028,6 @@ gimp_filter_tool_commit (GimpFilterTool *filter_tool)
config->filter_tool_max_recent);
}
}
gimp_filter_tool_halt (filter_tool);
}
static void
......
......@@ -215,6 +215,15 @@ gimp_free_select_tool_start (GimpFreeSelectTool *fst,
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
}
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)
......@@ -239,15 +248,6 @@ gimp_free_select_tool_commit (GimpFreeSelectTool *fst,
gimp_image_flush (gimp_display_get_image (display));
}
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,
......@@ -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:
......
......@@ -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;
......
......@@ -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:
......
......@@ -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
......
......@@ -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;
}
}
......
......@@ -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:
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment