[gnome-photos/wip/rishi/cancel-async: 2/2] offset-controller: Cancel tracker_queue_select during destruction



commit f2c88b8caf1a175a1243a37baba647825c698f7f
Author: Rafael Fonseca <r4f4rfs gmail com>
Date:   Mon Mar 21 16:41:30 2016 +0100

    offset-controller: Cancel tracker_queue_select during destruction
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763908

 src/photos-offset-controller.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/photos-offset-controller.c b/src/photos-offset-controller.c
index 3a15237..137c881 100644
--- a/src/photos-offset-controller.c
+++ b/src/photos-offset-controller.c
@@ -99,7 +99,7 @@ photos_offset_controller_cursor_next (GObject *source_object, GAsyncResult *res,
 static void
 photos_offset_controller_reset_count_query_executed (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
 {
-  PhotosOffsetController *self = PHOTOS_OFFSET_CONTROLLER (user_data);
+  PhotosOffsetController *self;
   TrackerSparqlConnection *connection = TRACKER_SPARQL_CONNECTION (source_object);
   TrackerSparqlCursor *cursor;
   GError *error;
@@ -108,10 +108,14 @@ photos_offset_controller_reset_count_query_executed (GObject *source_object, GAs
   cursor = tracker_sparql_connection_query_finish (connection, res, &error);
   if (error != NULL)
     {
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        g_warning ("Unable to query the item count: %s", error->message);
       g_error_free (error);
       return;
     }
 
+  self = PHOTOS_OFFSET_CONTROLLER (user_data);
+
   tracker_sparql_cursor_next_async (cursor,
                                     self->priv->cancellable,
                                     photos_offset_controller_cursor_next,
@@ -248,10 +252,10 @@ photos_offset_controller_reset_count (PhotosOffsetController *self)
 
   photos_tracker_queue_select (priv->queue,
                                query->sparql,
-                               NULL,
+                               priv->cancellable,
                                photos_offset_controller_reset_count_query_executed,
-                               g_object_ref (self),
-                               g_object_unref);
+                               self,
+                               NULL);
   photos_query_free (query);
 }
 


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