[gimp] app: avoid double-initialization of operation tools when changing layers



commit a21667821c9f6a2c5604699f4abc6e7d3579f3b1
Author: Ell <ell_se yahoo com>
Date:   Sat Sep 29 14:24:28 2018 -0400

    app: avoid double-initialization of operation tools when changing layers
    
    When re-activating an operation tool by clicking on a different
    drawable while the tool is active, we re-call the corresponding
    procedure to re-activate the tool, which implictly initializes it.
    Avoid initializaing it explicitly in addition to that, since this
    leads to the creation of a new config object by the filter tool,
    while the GUI still refers to the old, now-dead, config object,
    causing CRITICALs or segfaults when changing any parameter.

 app/display/gimpdisplayshell-tool-events.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index b918a029e5..23db94bbad 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -1842,8 +1842,6 @@ gimp_display_shell_initialize_tool (GimpDisplayShell *shell,
       (! gimp_image_is_empty (image) ||
        gimp_tool_control_get_handle_empty_image (active_tool->control)))
     {
-      initialized = TRUE;
-
       /*  initialize the current tool if it has no drawable  */
       if (! active_tool->drawable)
         {
@@ -1894,6 +1892,11 @@ gimp_display_shell_initialize_tool (GimpDisplayShell *shell,
               gimp_filter_history_add (gimp, procedure);
               gimp_ui_manager_activate_action (manager, "filters",
                                                "filters-reshow");
+
+              /*  the procedure already initialized the tool; don't
+               *  reinitialize it below, since this can lead to errors.
+               */
+              initialized = TRUE;
             }
           else
             {
@@ -1904,7 +1907,12 @@ gimp_display_shell_initialize_tool (GimpDisplayShell *shell,
           /*  make sure the newly created tool has the right state  */
           gimp_display_shell_update_focus (shell, TRUE, image_coords, state);
 
-          initialized = tool_manager_initialize_active (gimp, display);
+          if (! initialized)
+            initialized = tool_manager_initialize_active (gimp, display);
+        }
+      else
+        {
+          initialized = TRUE;
         }
     }
 


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