r2177 - trunk/src/target/OM-2007/openmoko-libs/libmokoui

njp at sita.openmoko.org njp at sita.openmoko.org
Wed Jun 6 16:54:35 CEST 2007


Author: njp
Date: 2007-06-06 16:54:34 +0200 (Wed, 06 Jun 2007)
New Revision: 2177

Modified:
   trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-tool-box.c
Log:
Added some error checking

Modified: trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-tool-box.c
===================================================================
--- trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-tool-box.c	2007-06-06 14:36:10 UTC (rev 2176)
+++ trunk/src/target/OM-2007/openmoko-libs/libmokoui/moko-finger-tool-box.c	2007-06-06 14:54:34 UTC (rev 2177)
@@ -189,8 +189,8 @@
 
     if ( !priv->background_pixbuf )
     {
-        gchar *filename;
-        if (filename = get_bg_pixmap_name (GTK_WIDGET (self)))
+        gchar *filename = NULL;
+        if ((filename = get_bg_pixmap_name (GTK_WIDGET (self))))
         {
           priv->background_pixbuf = gdk_pixbuf_new_from_file( filename, NULL);
           if (!priv->background_pixbuf)
@@ -211,14 +211,22 @@
         g_free (dirname);
         g_free (buttonfile);
     }
-    GdkPixbuf* pixbuf = gdk_pixbuf_scale_simple( priv->background_pixbuf, a->width, a->height, GDK_INTERP_BILINEAR );
+    GdkPixbuf* pixbuf = NULL;
     guint w = gdk_pixbuf_get_width( priv->button_pixbuf );
     guint h = gdk_pixbuf_get_height( priv->button_pixbuf );
     guint x = padding_left - 1;
     guint y = 0;
 
-    gdk_pixbuf_copy_area( priv->background_pixbuf, 0, 0, gdk_pixbuf_get_width( priv->background_pixbuf ), gdk_pixbuf_get_height( priv->background_pixbuf ), pixbuf, 0, 0 );
-
+    if (GDK_IS_PIXBUF (priv->background_pixbuf))
+    {
+        pixbuf = gdk_pixbuf_scale_simple( priv->background_pixbuf, 
+                                                     a->width, a->height,
+                                                     GDK_INTERP_BILINEAR );
+        gdk_pixbuf_copy_area( priv->background_pixbuf, 0, 0, 
+                              gdk_pixbuf_get_width( priv->background_pixbuf ),
+                              gdk_pixbuf_get_height( priv->background_pixbuf ),
+                              pixbuf, 0, 0 );
+    }
     guint composite_num;
     if ( maxButtonsPerPage == 0 )
         composite_num = priv->numberOfButtons - priv->leftButton;





More information about the commitlog mailing list