From 1c15bd71f70d92f49f6c31eb472d885e7e4c5091 Mon Sep 17 00:00:00 2001 From: Rob Kendrick Date: Tue, 25 Mar 2008 11:42:59 +0000 Subject: Make GTK thumbnail creation more robust, return false when unable to create pixmap for thumbnail. svn path=/trunk/netsurf/; revision=4049 --- gtk/gtk_thumbnail.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'gtk/gtk_thumbnail.c') diff --git a/gtk/gtk_thumbnail.c b/gtk/gtk_thumbnail.c index 6856ee771..e180da5f2 100644 --- a/gtk/gtk_thumbnail.c +++ b/gtk/gtk_thumbnail.c @@ -47,19 +47,35 @@ bool thumbnail_create(struct content *content, struct bitmap *bitmap, const char *url) { - GdkPixbuf *pixbuf = gtk_bitmap_get_primary(bitmap); - gint width = gdk_pixbuf_get_width(pixbuf); - gint height = gdk_pixbuf_get_height(pixbuf); - gint depth = (gdk_screen_get_system_visual(gdk_screen_get_default()))->depth; - GdkPixmap *pixmap = gdk_pixmap_new(NULL, content->width, content->width, depth); + GdkPixbuf *pixbuf; + gint width; + gint height; + gint depth; + GdkPixmap *pixmap; GdkPixbuf *big; + assert(content); + assert(bitmap); + + pixbuf = gtk_bitmap_get_primary(bitmap); + width = gdk_pixbuf_get_width(pixbuf); + height = gdk_pixbuf_get_height(pixbuf); + depth = (gdk_screen_get_system_visual(gdk_screen_get_default()))->depth; + LOG(("Trying to create a thumbnail pixmap for a content of %dx%d@%d", content->width, content->width, depth)); - assert(content); - assert(bitmap); - assert(pixmap); + pixmap = gdk_pixmap_new(NULL, content->width, content->width, depth); + + if (pixmap == NULL) { + /* the creation failed for some reason: most likely because + * we've been asked to create with with at least one dimention + * as zero. The RISC OS thumbnail generator returns false + * from here when it can't create a bitmap, so we assume it's + * safe to do so here too. + */ + return false; + } gdk_drawable_set_colormap(pixmap, gdk_colormap_get_system()); -- cgit v1.2.3