[gimp] Bug 776370 - Changing active layer breaks the GEGL operation dialog



commit dba909a9fa6cfee0a7b190277b65bc258576173a
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jan 23 00:00:03 2017 +0100

    Bug 776370 - Changing active layer breaks the GEGL operation dialog
    
    We can't just switch to a GimpOperationTool by using the normal
    gimp_context_set_tool() or gimp_context_tool_changed() because it
    needs additional initialization like setting an operation at all.
    
    In gimp_gegl_procedure_execute_async(), g_object_set_data() the used
    procedure on the newly created tool.
    
    In gimp_display_shell_initialize_tool(), when we re-create the active
    tool because of a drawable change, check for the procedure and invoke
    it again, instead of simply creating an empty operation tool by
    calling gimp_context_tool_changed().

 app/actions/gimpgeglprocedure.c            |   10 ++++++
 app/display/gimpdisplayshell-tool-events.c |   43 ++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/app/actions/gimpgeglprocedure.c b/app/actions/gimpgeglprocedure.c
index 7440443..ba6f517 100644
--- a/app/actions/gimpgeglprocedure.c
+++ b/app/actions/gimpgeglprocedure.c
@@ -326,6 +326,16 @@ gimp_gegl_procedure_execute_async (GimpProcedure  *procedure,
 
   if (GIMP_IS_OPERATION_TOOL (active_tool))
     {
+      /*  Remember the prodecure that created this tool, because we
+       *  can't just switch to an operation tool using
+       *  gimp_context_set_tool(), we also have to go through the
+       *  initialization code below, otherwise we end up with a dummy
+       *  tool that does nothing. See bug #776370.
+       */
+      g_object_set_data_full (G_OBJECT (active_tool), "gimp-gegl-procedure",
+                              g_object_ref (procedure),
+                              (GDestroyNotify) g_object_unref);
+
       gimp_operation_tool_set_operation (GIMP_OPERATION_TOOL (active_tool),
                                          procedure->original_name,
                                          gimp_procedure_get_label (procedure),
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index 45ec470..b3dbee4 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -29,7 +29,9 @@
 #include "config/gimpdisplayconfig.h"
 
 #include "core/gimp.h"
+#include "core/gimp-filter-history.h"
 #include "core/gimpimage.h"
+#include "core/gimpitem.h"
 
 #include "widgets/gimpcontrollers.h"
 #include "widgets/gimpcontrollerkeyboard.h"
@@ -1821,8 +1823,45 @@ gimp_display_shell_initialize_tool (GimpDisplayShell *shell,
                 (gimp_tool_control_get_dirty_mask (active_tool->control) &
                  GIMP_DIRTY_ACTIVE_DRAWABLE)))
         {
-          /*  create a new one, deleting the current  */
-          gimp_context_tool_changed (gimp_get_user_context (gimp));
+          GimpProcedure *procedure = g_object_get_data (G_OBJECT (active_tool),
+                                                        "gimp-gegl-procedure");
+
+          if (image == gimp_item_get_image (GIMP_ITEM (active_tool->drawable)))
+            {
+              /*  When changing between drawables if the *same* image,
+               *  halt the tool so it doesn't get committed on tool
+               *  change. This is a pure "probably better this way"
+               *  decision because the user is likely changing their
+               *  mind or was simply on the wrong layer. See bug
+               *  #776370.
+               */
+              tool_manager_control_active (gimp, GIMP_TOOL_ACTION_HALT,
+                                           active_tool->display);
+            }
+
+          if (procedure)
+            {
+              /*  We can't just recreate an operation tool, we must
+               *  make sure the right stuff gets set on it, so
+               *  re-activate the procedure that created it instead of
+               *  just calling gimp_context_tool_changed(). See
+               *  GimpGeglProcedure and bug #776370.
+               */
+              GimpImageWindow *window;
+              GimpUIManager   *manager;
+
+              window  = gimp_display_shell_get_window (shell);
+              manager = gimp_image_window_get_ui_manager (window);
+
+              gimp_filter_history_add (gimp, procedure);
+              gimp_ui_manager_activate_action (manager, "filters",
+                                               "filters-reshow");
+            }
+          else
+            {
+              /*  create a new one, deleting the current  */
+              gimp_context_tool_changed (gimp_get_user_context (gimp));
+            }
 
           /*  make sure the newly created tool has the right state  */
           gimp_display_shell_update_focus (shell, TRUE, image_coords, state);


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