failure return for gnome_pixmap_new_from_file*




Hi,

Seems like it would be convenient if gnome_pixmap_new_from_file
returned NULL if the load failed, instead of a half-built
widget. Here's my attempt at a patch but I don't really know if it's
OK.

Havoc Pennington
http://pobox.com/~hp

Index: gnome-libs/libgnomeui/gnome-pixmap.c
===================================================================
RCS file: /debian/home/gnomecvs/gnome-libs/libgnomeui/gnome-pixmap.c,v
retrieving revision 1.16
diff -u -r1.16 gnome-pixmap.c
--- gnome-pixmap.c	1998/03/16 21:19:20	1.16
+++ gnome-pixmap.c	1998/03/21 05:31:33
@@ -119,6 +119,11 @@
 	gpixmap = gtk_type_new (gnome_pixmap_get_type ());
 	gnome_pixmap_load_file (gpixmap, filename);
 
+	if (gpixmap->pixmap == NULL) {
+	  gtk_widget_destroy(gpixmap);
+	  return NULL;
+	}
+
 	return GTK_WIDGET (gpixmap);
 }
 
@@ -129,6 +134,11 @@
 
 	gpixmap = gtk_type_new (gnome_pixmap_get_type ());
 	gnome_pixmap_load_file_at_size (gpixmap, filename, width, height);
+
+	if (gpixmap->pixmap == NULL) {
+	  gtk_widget_destroy(gpixmap);
+	  return NULL;
+	}
 
 	return GTK_WIDGET (gpixmap);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]