changeset 34780:70d16eb7899e

Fix crash with icon that has unsupported format. This closes Bugzilla #2057.
author ib
date Wed, 18 Apr 2012 13:29:53 +0000
parents e59ffa59d825
children bdf54c7f4eb6
files gui/ui/widgets.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gui/ui/widgets.c	Wed Apr 18 09:04:05 2012 +0000
+++ b/gui/ui/widgets.c	Wed Apr 18 13:29:53 2012 +0000
@@ -73,7 +73,7 @@
 
 guiIcon_t guiIcon;
 
-static void gtkLoadIcon(GtkIconTheme *theme, gint size, GdkPixmap **gdkIcon, GdkBitmap **gdkIconMask)
+static int gtkLoadIcon(GtkIconTheme *theme, gint size, GdkPixmap **gdkIcon, GdkBitmap **gdkIconMask)
 {
     GdkPixbuf *pixbuf;
     guchar *data;
@@ -109,6 +109,8 @@
 
     /* start up GTK which realizes the pixmaps */
     gtk_main_iteration_do(FALSE);
+
+    return (pixbuf != NULL);
 }
 
 void gtkInit(void)
@@ -136,13 +138,15 @@
 
     theme = gtk_icon_theme_get_default();
 
-    gtkLoadIcon(theme, 16, &gdkIcon, &gdkIconMask);
+    if (gtkLoadIcon(theme, 16, &gdkIcon, &gdkIconMask)) {
     guiIcon.small      = GDK_PIXMAP_XID(gdkIcon);
     guiIcon.small_mask = GDK_PIXMAP_XID(gdkIconMask);
+    }
 
-    gtkLoadIcon(theme, 32, &gdkIcon, &gdkIconMask);
+    if (gtkLoadIcon(theme, 32, &gdkIcon, &gdkIconMask)) {
     guiIcon.normal      = GDK_PIXMAP_XID(gdkIcon);
     guiIcon.normal_mask = GDK_PIXMAP_XID(gdkIconMask);
+    }
 
     gtkLoadIcon(theme, 48, &gdkIcon, &gdkIconMask);