From 567bb69b4cd04a935a7bbdc7ce1a140f1abe4e6b Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Fri, 1 Aug 2008 17:29:51 +0200 Subject: [PATCH] Fix a warning about reffing NULL and add fallback code for file icons in the HitStore. --- libmmanager-gtk/mm-gtk-hit-store.c | 11 ++++++----- src/mm-hit-collection.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libmmanager-gtk/mm-gtk-hit-store.c b/libmmanager-gtk/mm-gtk-hit-store.c index 516ec99..07e542e 100644 --- a/libmmanager-gtk/mm-gtk-hit-store.c +++ b/libmmanager-gtk/mm-gtk-hit-store.c @@ -57,7 +57,7 @@ static void populate_from_hit_collection (MMGtkHitStore *self, MMHitCollection *collection) { - MMHit *hit; + MMHit *hit = NULL; GtkTreeIter iter; /* just append the hit collection to the model */ @@ -129,7 +129,6 @@ get_gfile_from_hit (MMHit *hit) GValue *uri_val; MMAttribute *uri_attr; const char *uri; - pairs = mm_hit_get_values (hit, MM_ATTRIBUTE_BASE_URI); @@ -150,18 +149,20 @@ value_set_gicon_from_hit (GValue *val, MMHit *hit) /* TODO: maybe we should support custom icons in some way... */ GFile *file; GFileInfo *info; + GIcon *icon; file = get_gfile_from_hit (hit); info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_ICON, 0, NULL, NULL); if (info) { - GIcon *icon; - icon = g_file_info_get_icon (info); - g_value_take_object (val, icon); g_object_unref (info); + } else { + /* fallback */ + icon = g_themed_icon_new ("document"); } + g_value_take_object (val, icon); g_object_unref (file); } diff --git a/src/mm-hit-collection.c b/src/mm-hit-collection.c index c103cef..14eb73b 100644 --- a/src/mm-hit-collection.c +++ b/src/mm-hit-collection.c @@ -99,7 +99,7 @@ mm_hit_collection_get_next_hit (MMHitCollection *c) if (details->hits->len == 0 || details->current_offset >= details->hits->len) { /* no hits in this collection or we already got all results */ - hit = NULL; + return NULL; } else { hit = g_ptr_array_index (details->hits, details->current_offset); details->current_offset++; -- 2.11.4.GIT