[grilo-plugins/wip/carlosg/tracker3: 28/40] tracker3: Handle errors on cursor_next() in resolve callback



commit f0963bc8199785d375b88e23df4e5f6339bf7d23
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun May 24 15:40:33 2020 +0200

    tracker3: Handle errors on cursor_next() in resolve callback
    
    Shuffle things so we don't miss errors there.

 src/tracker3/grl-tracker-source-api.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/src/tracker3/grl-tracker-source-api.c b/src/tracker3/grl-tracker-source-api.c
index 8d383671..54c99f48 100644
--- a/src/tracker3/grl-tracker-source-api.c
+++ b/src/tracker3/grl-tracker-source-api.c
@@ -361,6 +361,23 @@ tracker_resolve_cb (GObject      *source_object,
   cursor = tracker_sparql_statement_execute_finish (statement,
                                                     result, &tracker_error);
 
+  if (!cursor)
+    goto end_operation;
+
+  if (tracker_sparql_cursor_next (cursor, NULL, &tracker_error)) {
+    /* Translate Sparql result into Grilo result */
+    for (col = 0 ; col < tracker_sparql_cursor_get_n_columns (cursor) ; col++) {
+      fill_grilo_media_from_sparql (GRL_TRACKER_SOURCE (rs->source),
+                                    rs->media, cursor, col);
+    }
+    set_title_from_filename (rs->media);
+
+    rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL);
+  } else if (!tracker_error) {
+    rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL);
+  }
+
+ end_operation:
   if (tracker_error) {
     GRL_WARNING ("Could not execute sparql resolve query : %s",
                  tracker_error->message);
@@ -374,25 +391,8 @@ tracker_resolve_cb (GObject      *source_object,
 
     g_error_free (tracker_error);
     g_error_free (error);
-
-    goto end_operation;
   }
 
-
-  if (tracker_sparql_cursor_next (cursor, NULL, NULL)) {
-    /* Translate Sparql result into Grilo result */
-    for (col = 0 ; col < tracker_sparql_cursor_get_n_columns (cursor) ; col++) {
-      fill_grilo_media_from_sparql (GRL_TRACKER_SOURCE (rs->source),
-                                    rs->media, cursor, col);
-    }
-    set_title_from_filename (rs->media);
-
-    rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL);
-  } else {
-    rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL);
-  }
-
- end_operation:
   g_clear_object (&cursor);
 
   grl_tracker_op_free (os);


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