# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1336254117 0 # Node ID de49c1f284b2d73c13e549f4e92c34046646b995 # Parent cc10082567edd4bcd58596b4597d8523c342e074 Safety check for the icon resize code on Mac and GTK. diff -r cc10082567ed -r de49c1f284b2 gtk/dw.c --- a/gtk/dw.c Sat May 05 21:32:50 2012 +0000 +++ b/gtk/dw.c Sat May 05 21:41:57 2012 +0000 @@ -6963,14 +6963,17 @@ /* Internal function to keep HICNs from getting too big */ GdkPixbuf *_icon_resize(GdkPixbuf *ret) { - int pwidth = gdk_pixbuf_get_width(ret); - int pheight = gdk_pixbuf_get_height(ret); - - if(pwidth > 24 || pheight > 24) - { - GdkPixbuf *orig = ret; - ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR); - g_object_unref(G_OBJECT(orig)); + if(ret) + { + int pwidth = gdk_pixbuf_get_width(ret); + int pheight = gdk_pixbuf_get_height(ret); + + if(pwidth > 24 || pheight > 24) + { + GdkPixbuf *orig = ret; + ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR); + g_object_unref(G_OBJECT(orig)); + } } return ret; } diff -r cc10082567ed -r de49c1f284b2 gtk3/dw.c --- a/gtk3/dw.c Sat May 05 21:32:50 2012 +0000 +++ b/gtk3/dw.c Sat May 05 21:41:57 2012 +0000 @@ -5669,14 +5669,17 @@ /* Internal function to keep HICNs from getting too big */ GdkPixbuf *_icon_resize(GdkPixbuf *ret) { - int pwidth = gdk_pixbuf_get_width(ret); - int pheight = gdk_pixbuf_get_height(ret); - - if(pwidth > 24 || pheight > 24) - { - GdkPixbuf *orig = ret; - ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR); - g_object_unref(G_OBJECT(orig)); + if(ret) + { + int pwidth = gdk_pixbuf_get_width(ret); + int pheight = gdk_pixbuf_get_height(ret); + + if(pwidth > 24 || pheight > 24) + { + GdkPixbuf *orig = ret; + ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR); + g_object_unref(G_OBJECT(orig)); + } } return ret; } diff -r cc10082567ed -r de49c1f284b2 mac/dw.m --- a/mac/dw.m Sat May 05 21:32:50 2012 +0000 +++ b/mac/dw.m Sat May 05 21:41:57 2012 +0000 @@ -6819,14 +6819,17 @@ /* Internal function to keep HICNs from getting too big */ void _icon_resize(NSImage *image) { - NSSize size = [image size]; - if(size.width > 24 || size.height > 24) - { - if(size.width > 24) - size.width = 24; - if(size.height > 24) - size.height = 24; - [image setSize:size]; + if(image) + { + NSSize size = [image size]; + if(size.width > 24 || size.height > 24) + { + if(size.width > 24) + size.width = 24; + if(size.height > 24) + size.height = 24; + [image setSize:size]; + } } }