[gnome-photos] camera-cache: Throw an error if the cursor is empty



commit 92b1c0b01782340669403c4d3d315993fe342190
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Nov 29 14:43:34 2016 +0100

    camera-cache: Throw an error if the cursor is empty

 src/photos-camera-cache.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/src/photos-camera-cache.c b/src/photos-camera-cache.c
index 0b5b776..a92d82b 100644
--- a/src/photos-camera-cache.c
+++ b/src/photos-camera-cache.c
@@ -27,6 +27,7 @@
 #include "photos-query-builder.h"
 #include "photos-search-context.h"
 #include "photos-tracker-queue.h"
+#include "photos-utils.h"
 
 
 struct _PhotosCameraCache
@@ -48,6 +49,7 @@ photos_camera_cache_cursor_next (GObject *source_object, GAsyncResult *res, gpoi
   PhotosCameraCache *self;
   TrackerSparqlCursor *cursor = TRACKER_SPARQL_CURSOR (source_object);
   GError *error;
+  gboolean success;
   const gchar *manufacturer;
   const gchar *model;
   gchar *camera;
@@ -56,13 +58,22 @@ photos_camera_cache_cursor_next (GObject *source_object, GAsyncResult *res, gpoi
   self = PHOTOS_CAMERA_CACHE (g_task_get_source_object (task));
 
   error = NULL;
-  tracker_sparql_cursor_next_finish (cursor, res, &error);
+  /* Note that tracker_sparql_cursor_next_finish can return FALSE even
+   * without an error.
+   */
+  success = tracker_sparql_cursor_next_finish (cursor, res, &error);
   if (error != NULL)
     {
       g_task_return_error (task, error);
       goto out;
     }
 
+  if (!success)
+    {
+      g_task_return_new_error (task, PHOTOS_ERROR, 0, "Cursor is empty — possibly wrong SPARQL query");
+      goto out;
+    }
+
   manufacturer = tracker_sparql_cursor_get_string (cursor, 0, NULL);
   model = tracker_sparql_cursor_get_string (cursor, 1, NULL);
 


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