[gimp/gimp-2-10] Issue #1608: Gimp 2.10.0 and 2.10.2 crash immediately on start.



commit d997b2b89707d04f9c5776ebf60afb86b2a45c65
Author: Jehan <jehan girinstud io>
Date:   Sun Jun 24 15:44:31 2018 +0200

    Issue #1608: Gimp 2.10.0 and 2.10.2 crash immediately on start.
    
    If "gimp-swap-colors" or "gimp-default-colors" are present in the theme,
    yet broken somehow, GIMP would crash because it was not checking if the
    icons had been successfully loaded.
    Just make the relevant checks and output on standard error that the swap
    and/or default color areas are invisible.

 app/widgets/gimpfgbgeditor.c | 68 +++++++++++++++++++++++++++++++-------------
 1 file changed, 49 insertions(+), 19 deletions(-)
---
diff --git a/app/widgets/gimpfgbgeditor.c b/app/widgets/gimpfgbgeditor.c
index 845bc45e55..8ed3fcafdd 100644
--- a/app/widgets/gimpfgbgeditor.c
+++ b/app/widgets/gimpfgbgeditor.c
@@ -250,8 +250,10 @@ gimp_fg_bg_editor_expose (GtkWidget      *widget,
   cairo_t        *cr;
   GtkAllocation   allocation;
   gint            width, height;
-  gint            default_w, default_h;
-  gint            swap_w, swap_h;
+  gint            default_w = 0;
+  gint            default_h = 0;
+  gint            swap_w    = 0;
+  gint            swap_h    = 0;
   gint            rect_w, rect_h;
   GimpRGB         color;
   GimpRGB         transformed_color;
@@ -275,37 +277,65 @@ gimp_fg_bg_editor_expose (GtkWidget      *widget,
     editor->default_icon = gimp_widget_load_icon (widget,
                                                   GIMP_ICON_COLORS_DEFAULT, 12);
 
-  default_w = gdk_pixbuf_get_width  (editor->default_icon);
-  default_h = gdk_pixbuf_get_height (editor->default_icon);
-
-  if (default_w < width / 2 && default_h < height / 2)
+  if (editor->default_icon)
     {
-      gdk_cairo_set_source_pixbuf (cr, editor->default_icon,
-                                   0, height - default_h);
-      cairo_paint (cr);
+      default_w = gdk_pixbuf_get_width  (editor->default_icon);
+      default_h = gdk_pixbuf_get_height (editor->default_icon);
+
+      if (default_w < width / 2 && default_h < height / 2)
+        {
+          gdk_cairo_set_source_pixbuf (cr, editor->default_icon,
+                                       0, height - default_h);
+          cairo_paint (cr);
+        }
+      else
+        {
+          default_w = default_h = 0;
+        }
     }
   else
     {
-      default_w = default_h = 0;
+      g_printerr ("%s: invisible default colors area because of "
+                  "missing or broken icons in your theme.\n",
+                  G_STRFUNC);
+      /* If icon is too small, we may not draw it but still assigns some
+       * dimensions for the default color area, which will still exist,
+       * though not designated by an icon.
+       */
+      default_w = width / 4;
+      default_h = height / 4;
     }
 
   /*  draw the swap colors pixbuf  */
   if (! editor->swap_icon)
     editor->swap_icon = gimp_widget_load_icon (widget,
                                                GIMP_ICON_COLORS_SWAP, 12);
-
-  swap_w = gdk_pixbuf_get_width  (editor->swap_icon);
-  swap_h = gdk_pixbuf_get_height (editor->swap_icon);
-
-  if (swap_w < width / 2 && swap_h < height / 2)
+  if (editor->swap_icon)
     {
-      gdk_cairo_set_source_pixbuf (cr, editor->swap_icon,
-                                   width - swap_w, 0);
-      cairo_paint (cr);
+      swap_w = gdk_pixbuf_get_width  (editor->swap_icon);
+      swap_h = gdk_pixbuf_get_height (editor->swap_icon);
+
+      if (swap_w < width / 2 && swap_h < height / 2)
+        {
+          gdk_cairo_set_source_pixbuf (cr, editor->swap_icon,
+                                       width - swap_w, 0);
+          cairo_paint (cr);
+        }
+      else
+        {
+          swap_w = swap_h = 0;
+        }
     }
   else
     {
-      swap_w = swap_h = 0;
+      g_printerr ("%s: invisible color swap area because of missing or "
+                  "broken icons in your theme.\n", G_STRFUNC);
+      /* If icon is too small, we may not draw it but still assigns some
+       * dimensions for the color swap area, which will still exist,
+       * though not designated by an icon.
+       */
+      swap_w = width / 4;
+      swap_h = height / 4;
     }
 
   rect_h = height - MAX (default_h, swap_h) - 2;


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