[gnome-photos] Skip icon-less documents for collection icons and effects



commit aeb1f79d12b428dcf0fe04beb6501602f6a90f71
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 b216c04..050cbea 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -136,7 +136,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);
 
@@ -217,7 +220,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);
 }
 
@@ -652,6 +656,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;
@@ -669,14 +674,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]