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.
This commit is contained in:
Michael Natterer 2016-01-25 02:51:45 +01:00
parent 6a2f200b34
commit d2d2920af6
1 changed files with 18 additions and 10 deletions

View File

@ -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,
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)