Mercurial > dwindows
changeset 1709:de49c1f284b2
Safety check for the icon resize code on Mac and GTK.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 05 May 2012 21:41:57 +0000 |
parents | cc10082567ed |
children | b217cf9161c7 |
files | gtk/dw.c gtk3/dw.c mac/dw.m |
diffstat | 3 files changed, 33 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- 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; }
--- 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]; + } } }