[gimp] app: fix handling multi-drawables selected in bucket fill tool.



commit 35cef548993aab61ef429f9f69a1af24f25c0087
Author: Jehan <jehan girinstud io>
Date:   Wed Feb 9 00:24:35 2022 +0100

    app: fix handling multi-drawables selected in bucket fill tool.
    
    We were getting a critical when selecting multiple drawables (either
    changing layer selection while the tool is ON, or starting with multiple
    selection). We should not have assert code here, just handle the case
    gracefully with a normal error message when trying to fill on several
    layers at once.

 app/tools/gimpbucketfilltool.c | 13 +++++++------
 app/tools/tools-enums.c        |  6 +++---
 app/tools/tools-enums.h        |  6 +++---
 3 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 0f1916722a..7d29883895 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -1055,15 +1055,16 @@ gimp_bucket_fill_tool_reset_line_art (GimpBucketFillTool *tool)
   if (image)
     {
       GList        *drawables = gimp_image_get_selected_drawables (image);
-      GimpDrawable *drawable;
+      GimpDrawable *drawable  = NULL;
 
-      g_return_if_fail (g_list_length (drawables) == 1);
-      drawable = drawables->data;
+      if (g_list_length (drawables) == 1)
+        {
+          drawable = drawables->data;
+          if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
+            drawable = NULL;
+        }
       g_list_free (drawables);
 
-      if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
-        drawable = NULL;
-
       if (options->line_art_source == GIMP_LINE_ART_SOURCE_SAMPLE_MERGED)
         {
           GimpImageProxy *image_proxy = gimp_image_proxy_new (image);
diff --git a/app/tools/tools-enums.c b/app/tools/tools-enums.c
index e2a3b4070f..aad8d49488 100644
--- a/app/tools/tools-enums.c
+++ b/app/tools/tools-enums.c
@@ -55,9 +55,9 @@ gimp_line_art_source_get_type (void)
   static const GimpEnumDesc descs[] =
   {
     { GIMP_LINE_ART_SOURCE_SAMPLE_MERGED, NC_("line-art-source", "All visible layers"), NULL },
-    { GIMP_LINE_ART_SOURCE_ACTIVE_LAYER, NC_("line-art-source", "Active layer"), NULL },
-    { GIMP_LINE_ART_SOURCE_LOWER_LAYER, NC_("line-art-source", "Layer below the active one"), NULL },
-    { GIMP_LINE_ART_SOURCE_UPPER_LAYER, NC_("line-art-source", "Layer above the active one"), NULL },
+    { GIMP_LINE_ART_SOURCE_ACTIVE_LAYER, NC_("line-art-source", "Selected layer"), NULL },
+    { GIMP_LINE_ART_SOURCE_LOWER_LAYER, NC_("line-art-source", "Layer below the selected one"), NULL },
+    { GIMP_LINE_ART_SOURCE_UPPER_LAYER, NC_("line-art-source", "Layer above the selected one"), NULL },
     { 0, NULL, NULL }
   };
 
diff --git a/app/tools/tools-enums.h b/app/tools/tools-enums.h
index a7dc3167b6..54ad51954d 100644
--- a/app/tools/tools-enums.h
+++ b/app/tools/tools-enums.h
@@ -59,9 +59,9 @@ GType gimp_line_art_source_get_type (void) G_GNUC_CONST;
 typedef enum
 {
   GIMP_LINE_ART_SOURCE_SAMPLE_MERGED, /*< desc="All visible layers" >*/
-  GIMP_LINE_ART_SOURCE_ACTIVE_LAYER,  /*< desc="Active layer" >*/
-  GIMP_LINE_ART_SOURCE_LOWER_LAYER,   /*< desc="Layer below the active one" >*/
-  GIMP_LINE_ART_SOURCE_UPPER_LAYER    /*< desc="Layer above the active one" >*/
+  GIMP_LINE_ART_SOURCE_ACTIVE_LAYER,  /*< desc="Selected layer" >*/
+  GIMP_LINE_ART_SOURCE_LOWER_LAYER,   /*< desc="Layer below the selected one" >*/
+  GIMP_LINE_ART_SOURCE_UPPER_LAYER    /*< desc="Layer above the selected one" >*/
 } GimpLineArtSource;
 
 


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