Merge commit 'cbb35cca'
[projects/chimara/chimara.git] / libchimara / graphics.c
index 0011a8d56f19c64674f28cb356f50edc5b7163af..0c3215a6f3c66f01b1c50bb63a259ff844a49d3f 100644 (file)
@@ -63,6 +63,7 @@ load_image_from_blorb(giblorb_result_t resource, glui32 image, gint width, gint
        g_mutex_unlock(glk_data->resource_lock);
 
        info->pixbuf = gdk_pixbuf_loader_get_pixbuf(loader);
+       gdk_pixbuf_ref(info->pixbuf);
 
        g_object_unref(loader);
        return info;
@@ -88,6 +89,7 @@ load_image_from_file(const gchar *filename, glui32 image, gint width, gint heigh
                g_free(info);
                return NULL;
        }
+       gdk_pixbuf_ref(info->pixbuf);
 
        return info;
 }
@@ -121,6 +123,9 @@ load_image_in_cache(glui32 image, gint width, gint height)
                info = load_image_from_blorb(resource, image, width, height);
        }
 
+       if(info == NULL)
+               return NULL;
+
        /* Store the image in the cache */
        gdk_threads_enter();
 
@@ -130,7 +135,6 @@ load_image_in_cache(glui32 image, gint width, gint height)
                g_free(head);
                glk_data->image_cache = g_slist_remove_link(glk_data->image_cache, glk_data->image_cache);
        }
-       gdk_pixbuf_ref(info->pixbuf);
        info->width = gdk_pixbuf_get_width(info->pixbuf);
        info->height = gdk_pixbuf_get_height(info->pixbuf);
        glk_data->image_cache = g_slist_prepend(glk_data->image_cache, info);
@@ -228,11 +232,11 @@ image_cache_find(struct image_info* to_find)
  * @height: Pointer to a location at which to store the image's height.
  *
  * This gets information about the image resource with the given identifier. It
- * returns %TRUE if there is such an image, and %FALSE if not. You can also pass
- * pointers to width and height variables; if the image exists, the variables
- * will be filled in with the width and height of the image, in pixels. (You can
- * pass %NULL for either width or height if you don't care about that 
- * information.)
+ * returns %TRUE (1) if there is such an image, and %FALSE (0) if not. You can
+ * also pass pointers to width and height variables; if the image exists, the
+ * variables will be filled in with the width and height of the image, in
+ * pixels. (You can pass %NULL for either width or height if you don't care
+ * about that information.)
  * 
  * <note><para>
  *   You should always use this function to measure the size of images when you