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



commit d2d2920af65136c81895a65b86aecc914aec1fd8
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jan 25 02:51:45 2016 +0100

    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.

 app/tools/tool_manager.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c
index 48d7bfa..4d09c19 100644
--- a/app/tools/tool_manager.c
+++ b/app/tools/tool_manager.c
@@ -673,6 +673,23 @@ tool_manager_tool_changed (GimpContext     *user_context,
       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))
     {
       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)
     {
-      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);
+      GimpTool *active_tool = tool_manager->active_tool;
 
       /*  disconnect the old tool's context  */
       if (active_tool->tool_info)


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