[gthumb] file list: fixed crash when the file icon is not available



commit b9ecf3f4b2fc4631e5c5c689abb3315c40914636
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Aug 18 11:45:13 2012 +0200

    file list: fixed crash when the file icon is not available

 gthumb/gth-file-list.c  |    1 +
 gthumb/gth-icon-cache.c |   13 ++++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/gthumb/gth-file-list.c b/gthumb/gth-file-list.c
index afc10ef..61befde 100644
--- a/gthumb/gth-file-list.c
+++ b/gthumb/gth-file-list.c
@@ -1290,6 +1290,7 @@ gth_file_list_set_thumb_size (GthFileList *file_list,
 
 	gth_icon_cache_free (file_list->priv->icon_cache);
 	file_list->priv->icon_cache = gth_icon_cache_new (gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (file_list))), size / 2);
+	gth_icon_cache_set_fallback (file_list->priv->icon_cache, g_themed_icon_new ("image-x-generic"));
 
 	gth_file_view_set_thumbnail_size (GTH_FILE_VIEW (file_list->priv->view), file_list->priv->thumb_size);
 
diff --git a/gthumb/gth-icon-cache.c b/gthumb/gth-icon-cache.c
index 4c926a0..514c48d 100644
--- a/gthumb/gth-icon-cache.c
+++ b/gthumb/gth-icon-cache.c
@@ -71,8 +71,6 @@ gth_icon_cache_set_fallback (GthIconCache *icon_cache,
 	if (icon_cache->fallback_icon != NULL)
 		g_object_unref (icon_cache->fallback_icon);
 	icon_cache->fallback_icon = icon;
-	if (icon_cache->fallback_icon != NULL)
-		g_object_ref (icon_cache->fallback_icon);
 }
 
 
@@ -100,9 +98,14 @@ GdkPixbuf *
 gth_icon_cache_get_pixbuf (GthIconCache *icon_cache,
 			   GIcon        *icon)
 {
-	GdkPixbuf *pixbuf;
+	GdkPixbuf *pixbuf = NULL;
+
+	if (icon == NULL)
+		icon = icon_cache->fallback_icon;
+
+	if (icon != NULL)
+		pixbuf = g_hash_table_lookup (icon_cache->cache, icon);
 
-	pixbuf = g_hash_table_lookup (icon_cache->cache, icon);
 	if (pixbuf != NULL)
 		return g_object_ref (pixbuf);
 
@@ -112,7 +115,7 @@ gth_icon_cache_get_pixbuf (GthIconCache *icon_cache,
 	if ((pixbuf == NULL) && (icon_cache->fallback_icon != NULL))
 		pixbuf = _g_icon_get_pixbuf (icon_cache->fallback_icon, icon_cache->icon_size, icon_cache->icon_theme);
 
-	if (pixbuf != NULL)
+	if ((icon != NULL) && (pixbuf != NULL))
 		g_hash_table_insert (icon_cache->cache, g_object_ref (icon), g_object_ref (pixbuf));
 
 	return pixbuf;



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