[gtk+/gtk-2-24] [Quartz Bug 663182] NSImage throws an exception from _gtk_quartz_create_image_from_pixbuf()
- From: John Ralls <jralls src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] [Quartz Bug 663182] NSImage throws an exception from _gtk_quartz_create_image_from_pixbuf()
- Date: Mon, 7 Nov 2011 21:41:31 +0000 (UTC)
commit fadc82ad2647277628fd140514b54473dbeb2f4c
Author: John Ralls <jralls ceridwen us>
Date: Mon Nov 7 13:04:59 2011 -0800
[Quartz Bug 663182] NSImage throws an exception from _gtk_quartz_create_image_from_pixbuf()
If _gtk_quartz_create_image_from_pixbuf is given a pixbuf with size 0, 0
or which produces an NSImage with size 0.0, 0.0, it throws an exception
which Gtk doesn't handle.
gtk/gtkdnd-quartz.c | 5 +++++
gtk/gtkquartz.c | 8 ++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index e22fc70..6be1c15 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -1100,6 +1100,11 @@ gtk_drag_begin_idle (gpointer arg)
point = [info->nsevent locationInWindow];
drag_image = _gtk_quartz_create_image_from_pixbuf (info->icon_pixbuf);
+ if (drag_image == NULL)
+ {
+ g_object_unref (info->context);
+ return FALSE;
+ }
[nswindow dragImage:drag_image
at:point
diff --git a/gtk/gtkquartz.c b/gtk/gtkquartz.c
index 4fdc915..286b418 100644
--- a/gtk/gtkquartz.c
+++ b/gtk/gtkquartz.c
@@ -35,9 +35,11 @@ _gtk_quartz_create_image_from_pixbuf (GdkPixbuf *pixbuf)
int rowstride, pixbuf_width, pixbuf_height;
gboolean has_alpha;
NSImage *nsimage;
+ NSSize nsimage_size;
pixbuf_width = gdk_pixbuf_get_width (pixbuf);
pixbuf_height = gdk_pixbuf_get_height (pixbuf);
+ g_return_val_if_fail (pixbuf_width == 0 && pixbuf_height == 0, NULL);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
@@ -57,6 +59,12 @@ _gtk_quartz_create_image_from_pixbuf (GdkPixbuf *pixbuf)
CGColorSpaceRelease (colorspace);
nsimage = [[NSImage alloc] initWithSize:NSMakeSize (pixbuf_width, pixbuf_height)];
+ nsimage_size = [nsimage size];
+ if (nsimage_size.width == 0.0 && nsimage_size.height == 0.0)
+ {
+ [nsimage release];
+ g_return_val_if_fail (FALSE, NULL);
+ }
[nsimage lockFocus];
context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]