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



commit 7886bdc2a9863a783348fcb01576bda0e673588a
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.
    
    (cherry picked from commit d997b2b89707d04f9c5776ebf60afb86b2a45c65 with
    conflicts resolved)

 app/widgets/gimpfgbgeditor.c | 72 +++++++++++++++++++++++++++++++-------------
 1 file changed, 51 insertions(+), 21 deletions(-)
---
diff --git a/app/widgets/gimpfgbgeditor.c b/app/widgets/gimpfgbgeditor.c
index e2846ab307..2153bf1a11 100644
--- a/app/widgets/gimpfgbgeditor.c
+++ b/app/widgets/gimpfgbgeditor.c
@@ -251,8 +251,10 @@ gimp_fg_bg_editor_draw (GtkWidget *widget,
   GtkBorder        padding;
   GdkRectangle     rect;
   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;
   GimpRGB          color;
   GimpRGB          transformed_color;
 
@@ -276,39 +278,67 @@ gimp_fg_bg_editor_draw (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,
-                                   border.left,
-                                   height - border.bottom - 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,
+                                       border.left,
+                                       height - border.bottom - 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 - border.right - swap_w,
-                                   border.top);
-      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 - border.right - swap_w,
+                                       border.top);
+          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.width  = width  - MAX (default_w, swap_w) - 4 - border.top  - border.bottom;


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