[gimp] Bug 795493 - Warning when removing a text layer



commit 8d5447645762880c80f223f6de99b27ab4c8e64f
Author: Michael Natterer <mitch gimp org>
Date:   Tue Apr 24 02:49:03 2018 +0200

    Bug 795493 - Warning when removing a text layer
    
    In gimp_text_tool_connect(), when auto-removing empty text layers upon
    text layer or tool change, make sure we don't try to remove a layer
    that has already been removed, which can happen if this function is
    reached *because* somehow the layer was removed externally (e.g. by
    the user in the layers dialog).

 app/tools/gimptexttool.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index 8ca768f..c5156da 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -1186,18 +1186,28 @@ gimp_text_tool_connect (GimpTextTool  *text_tool,
   if (text_tool->layer != layer)
     {
       if (text_tool->layer)
-        g_signal_handlers_disconnect_by_func (text_tool->layer,
-                                              gimp_text_tool_layer_notify,
-                                              text_tool);
+        {
+          g_signal_handlers_disconnect_by_func (text_tool->layer,
+                                                gimp_text_tool_layer_notify,
+                                                text_tool);
 
-      gimp_text_tool_remove_empty_text_layer (text_tool);
+          /*  don't try to remove the layer if it is not attached,
+           *  which can happen if we got here because the layer was
+           *  somehow deleted from the image (like by the user in the
+           *  layers dialog).
+           */
+          if (gimp_item_is_attached (GIMP_ITEM (text_tool->layer)))
+            gimp_text_tool_remove_empty_text_layer (text_tool);
+        }
 
       text_tool->layer = layer;
 
       if (layer)
-        g_signal_connect_object (text_tool->layer, "notify",
-                                 G_CALLBACK (gimp_text_tool_layer_notify),
-                                 text_tool, 0);
+        {
+          g_signal_connect_object (text_tool->layer, "notify",
+                                   G_CALLBACK (gimp_text_tool_layer_notify),
+                                   text_tool, 0);
+        }
     }
 }
 


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