[gnome-photos/gnome-3-12] Skip icon-less documents for collection icons and effects
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/gnome-3-12] Skip icon-less documents for collection icons and effects
- Date: Tue, 15 Apr 2014 10:57:54 +0000 (UTC)
commit 2f04d25f3ab422653620b6e26e631d9ae1135604
Author: Debarshi Ray <debarshir gnome org>
Date: Sat Mar 22 21:23:54 2014 +0100
Skip icon-less documents for collection icons and effects
This can happen if we failed to load the icon based on the MIME or
RDF type. A very unlikely possibility, but no harm in being robust
against it.
Fixes: https://bugzilla.gnome.org/726903
src/photos-base-item.c | 22 +++++++++++++++++-----
src/photos-collection-icon-watcher.c | 3 ++-
2 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 1080417..b1a7860 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -135,7 +135,10 @@ photos_base_item_check_effects_and_update_info (PhotosBaseItem *self)
PhotosBaseItemPrivate *priv = self->priv;
GIcon *pix;
GList *emblem_icons = NULL;
- GdkPixbuf *emblemed_pixbuf;
+ GdkPixbuf *emblemed_pixbuf = NULL;
+
+ if (priv->original_icon == NULL)
+ goto out;
emblemed_pixbuf = g_object_ref (priv->original_icon);
@@ -216,7 +219,8 @@ photos_base_item_check_effects_and_update_info (PhotosBaseItem *self)
g_signal_emit (self, signals[INFO_UPDATED], 0);
- g_object_unref (emblemed_pixbuf);
+ out:
+ g_clear_object (&emblemed_pixbuf);
g_list_free_full (emblem_icons, g_object_unref);
}
@@ -651,6 +655,7 @@ photos_base_item_update_icon_from_type (PhotosBaseItem *self)
{
PhotosBaseItemPrivate *priv = self->priv;
GdkPixbuf *pixbuf = NULL;
+ GError *error;
GIcon *icon = NULL;
GtkIconInfo *info = NULL;
GtkIconTheme *theme;
@@ -668,14 +673,21 @@ photos_base_item_update_icon_from_type (PhotosBaseItem *self)
icon,
icon_size,
GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
- if (info != NULL)
+ if (info == NULL)
+ goto out;
+
+ error = NULL;
+ pixbuf = gtk_icon_info_load_icon (info, &error);
+ if (error != NULL)
{
- pixbuf = gtk_icon_info_load_icon (info, NULL);
- /* TODO: use a GError */
+ g_warning ("Unable to load pixbuf: %s", error->message);
+ g_error_free (error);
+ goto out;
}
photos_base_item_set_original_icon (self, pixbuf);
+ out:
g_clear_object (&pixbuf);
g_clear_object (&info);
g_clear_object (&icon);
diff --git a/src/photos-collection-icon-watcher.c b/src/photos-collection-icon-watcher.c
index f3344c3..d13e778 100644
--- a/src/photos-collection-icon-watcher.c
+++ b/src/photos-collection-icon-watcher.c
@@ -84,7 +84,8 @@ photos_collection_icon_watcher_create_collection_icon (PhotosCollectionIconWatch
PhotosBaseItem *item = PHOTOS_BASE_ITEM (l->data);
original_icon = photos_base_item_get_original_icon (item);
- icons = g_list_prepend (icons, g_object_ref (original_icon));
+ if (original_icon != NULL)
+ icons = g_list_prepend (icons, g_object_ref (original_icon));
}
icons = g_list_reverse (icons);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]