[gnome-photos] camera-cache: Be robust against PhotosTrackerQueue failures



commit b1916505d9065a939c1c2ed28381ff9050ac3a42
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Dec 27 18:34:20 2013 +0100

    camera-cache: Be robust against PhotosTrackerQueue failures
    
    Fixes: https://bugzilla.gnome.org/704947

 src/photos-camera-cache.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-camera-cache.c b/src/photos-camera-cache.c
index e02fdce..5c1e1aa 100644
--- a/src/photos-camera-cache.c
+++ b/src/photos-camera-cache.c
@@ -30,6 +30,7 @@
 
 struct _PhotosCameraCachePrivate
 {
+  GError *queue_error;
   GHashTable *cache;
   PhotosTrackerQueue *queue;
 };
@@ -139,8 +140,10 @@ static void
 photos_camera_cache_finalize (GObject *object)
 {
   PhotosCameraCache *self = PHOTOS_CAMERA_CACHE (object);
+  PhotosCameraCachePrivate *priv = self->priv;
 
-  g_hash_table_unref (self->priv->cache);
+  g_clear_error (&priv->queue_error);
+  g_hash_table_unref (priv->cache);
 
   G_OBJECT_CLASS (photos_camera_cache_parent_class)->finalize (object);
 }
@@ -155,7 +158,7 @@ photos_camera_cache_init (PhotosCameraCache *self)
   priv = self->priv;
 
   priv->cache = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
-  priv->queue = photos_tracker_queue_dup_singleton (NULL, NULL);
+  priv->queue = photos_tracker_queue_dup_singleton (NULL, &priv->queue_error);
 }
 
 
@@ -201,6 +204,12 @@ photos_camera_cache_get_camera_async (PhotosCameraCache *self,
       goto out;
     }
 
+  if (G_UNLIKELY (priv->queue == NULL))
+    {
+      g_task_return_error (task, g_error_copy (priv->queue_error));
+      goto out;
+    }
+
   query = photos_query_builder_equipment_query (id);
   photos_tracker_queue_select (priv->queue,
                                query->sparql,


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