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

app: fix changing tools to not prematurely change the old tool

Commit the old tool before even creating the new tool. Old and new
tool might be the same and share tool options, and we don't want
the new tool's initialization to mess up the old tool's state.

Fixes changing from one GEGL operation to another without explicitly
confirming the first operation. The bug only killed the cached filter
result, but that's bad enough.
parent 6a2f200b
...@@ -673,6 +673,23 @@ tool_manager_tool_changed (GimpContext *user_context, ...@@ -673,6 +673,23 @@ tool_manager_tool_changed (GimpContext *user_context,
return; return;
} }
if (tool_manager->active_tool)
{
GimpTool *active_tool = tool_manager->active_tool;
GimpDisplay *display;
/* NULL image returns any display (if there is any) */
display = gimp_tool_has_image (active_tool, NULL);
/* commit the old tool's operation before creating the new tool
* because creating a tool might mess with the old tool's
* options (old and new tool might be the same)
*/
if (display)
tool_manager_control_active (user_context->gimp, GIMP_TOOL_ACTION_COMMIT,
display);
}
if (g_type_is_a (tool_info->tool_type, GIMP_TYPE_TOOL)) if (g_type_is_a (tool_info->tool_type, GIMP_TYPE_TOOL))
{ {
new_tool = g_object_new (tool_info->tool_type, new_tool = g_object_new (tool_info->tool_type,
...@@ -688,16 +705,7 @@ tool_manager_tool_changed (GimpContext *user_context, ...@@ -688,16 +705,7 @@ tool_manager_tool_changed (GimpContext *user_context,
if (tool_manager->active_tool) if (tool_manager->active_tool)
{ {
GimpTool *active_tool = tool_manager->active_tool; GimpTool *active_tool = tool_manager->active_tool;
GimpDisplay *display;
/* NULL image returns any display (if there is any) */
display = gimp_tool_has_image (active_tool, NULL);
/* commit the old tool's operation */
if (display)
tool_manager_control_active (user_context->gimp, GIMP_TOOL_ACTION_COMMIT,
display);
/* disconnect the old tool's context */ /* disconnect the old tool's context */
if (active_tool->tool_info) if (active_tool->tool_info)
......
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