[gnome-photos/wip/rishi/query: 8/8] Let PhotosQuery instances be reference counted



commit d100ed746601455fceda1b85ac17912c33122255
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Sep 13 18:59:17 2017 +0200

    Let PhotosQuery instances be reference counted
    
    ... by turning it into a GObject.
    
    The other option was to implement a boxed type with its own reference
    counting using g_atomic_*. However, there is no proof that using a
    GObject will measurably affect performance and we get the reference
    counting for free.
    
    This paves the way for reduced memory fragmentation, by removing the
    need to copy the sparql and tag fields of a PhotosQuery.

 src/photos-camera-cache.c            |    4 +-
 src/photos-collection-icon-watcher.c |    2 +-
 src/photos-create-collection-job.c   |    4 +-
 src/photos-delete-item-job.c         |    4 +-
 src/photos-fetch-collections-job.c   |    4 +-
 src/photos-fetch-ids-job.c           |    4 +-
 src/photos-offset-controller.c       |    4 +-
 src/photos-properties-dialog.c       |    4 +-
 src/photos-query.c                   |  177 ++++++++++++++++++++++++++++++----
 src/photos-query.h                   |   20 ++--
 src/photos-set-collection-job.c      |    4 +-
 src/photos-single-item-job.c         |    4 +-
 src/photos-tracker-change-monitor.c  |    2 +-
 src/photos-tracker-controller.c      |   14 +--
 src/photos-tracker-queue.c           |   39 ++++++--
 src/photos-update-mtime-job.c        |    4 +-
 src/photos-utils.c                   |    4 +-
 17 files changed, 227 insertions(+), 71 deletions(-)
---
diff --git a/src/photos-camera-cache.c b/src/photos-camera-cache.c
index 8a3bf40..b174093 100644
--- a/src/photos-camera-cache.c
+++ b/src/photos-camera-cache.c
@@ -202,7 +202,7 @@ photos_camera_cache_get_camera_async (PhotosCameraCache *self,
 {
   GApplication *app;
   GTask *task;
-  PhotosQuery *query;
+  PhotosQuery *query = NULL;
   PhotosSearchContextState *state;
   const gchar *camera;
 
@@ -233,9 +233,9 @@ photos_camera_cache_get_camera_async (PhotosCameraCache *self,
                                photos_camera_cache_equipment_query_executed,
                                g_object_ref (task),
                                g_object_unref);
-  photos_query_free (query);
 
  out:
+  g_clear_object (&query);
   g_object_unref (task);
 }
 
diff --git a/src/photos-collection-icon-watcher.c b/src/photos-collection-icon-watcher.c
index dff1928..dbcf257 100644
--- a/src/photos-collection-icon-watcher.c
+++ b/src/photos-collection-icon-watcher.c
@@ -350,7 +350,7 @@ photos_collection_icon_watcher_start (PhotosCollectionIconWatcher *self)
                                photos_collection_icon_watcher_query_executed,
                                g_object_ref (self),
                                g_object_unref);
-  photos_query_free (query);
+  g_object_unref (query);
 }
 
 
diff --git a/src/photos-create-collection-job.c b/src/photos-create-collection-job.c
index bf3f8e9..084faa6 100644
--- a/src/photos-create-collection-job.c
+++ b/src/photos-create-collection-job.c
@@ -202,7 +202,7 @@ photos_create_collection_job_run (PhotosCreateCollectionJob *self,
 {
   GApplication *app;
   GTask *task;
-  PhotosQuery *query;
+  PhotosQuery *query = NULL;
   PhotosSearchContextState *state;
 
   task = g_task_new (self, cancellable, callback, user_data);
@@ -224,8 +224,8 @@ photos_create_collection_job_run (PhotosCreateCollectionJob *self,
                                      photos_create_collection_job_query_executed,
                                      g_object_ref (task),
                                      g_object_unref);
-  photos_query_free (query);
 
  out:
+  g_clear_object (&query);
   g_object_unref (task);
 }
diff --git a/src/photos-delete-item-job.c b/src/photos-delete-item-job.c
index 98eb796..39afbcd 100644
--- a/src/photos-delete-item-job.c
+++ b/src/photos-delete-item-job.c
@@ -168,7 +168,7 @@ photos_delete_item_job_run (PhotosDeleteItemJob *self,
 {
   GApplication *app;
   GTask *task;
-  PhotosQuery *query;
+  PhotosQuery *query = NULL;
   PhotosSearchContextState *state;
 
   task = g_task_new (self, cancellable, callback, user_data);
@@ -190,8 +190,8 @@ photos_delete_item_job_run (PhotosDeleteItemJob *self,
                                photos_delete_item_job_query_executed,
                                g_object_ref (task),
                                g_object_unref);
-  photos_query_free (query);
 
  out:
+  g_clear_object (&query);
   g_object_unref (task);
 }
diff --git a/src/photos-fetch-collections-job.c b/src/photos-fetch-collections-job.c
index e86d24a..70a9198 100644
--- a/src/photos-fetch-collections-job.c
+++ b/src/photos-fetch-collections-job.c
@@ -237,7 +237,7 @@ photos_fetch_collections_job_run (PhotosFetchCollectionsJob *self,
 {
   GApplication *app;
   GTask *task;
-  PhotosQuery *query;
+  PhotosQuery *query = NULL;
   PhotosSearchContextState *state;
 
   task = g_task_new (self, cancellable, callback, user_data);
@@ -259,8 +259,8 @@ photos_fetch_collections_job_run (PhotosFetchCollectionsJob *self,
                                photos_fetch_collections_job_query_executed,
                                g_object_ref (task),
                                g_object_unref);
-  photos_query_free (query);
 
  out:
+  g_clear_object (&query);
   g_object_unref (task);
 }
diff --git a/src/photos-fetch-ids-job.c b/src/photos-fetch-ids-job.c
index 7512eb7..1ac49db 100644
--- a/src/photos-fetch-ids-job.c
+++ b/src/photos-fetch-ids-job.c
@@ -223,7 +223,7 @@ photos_fetch_ids_job_run (PhotosFetchIdsJob *self,
                           GAsyncReadyCallback callback,
                           gpointer user_data)
 {
-  PhotosQuery *query;
+  PhotosQuery *query = NULL;
   gchar *str;
   GTask *task;
 
@@ -247,8 +247,8 @@ photos_fetch_ids_job_run (PhotosFetchIdsJob *self,
                                photos_fetch_ids_job_query_executed,
                                g_object_ref (task),
                                g_object_unref);
-  photos_query_free (query);
 
  out:
+  g_clear_object (&query);
   g_object_unref (task);
 }
diff --git a/src/photos-offset-controller.c b/src/photos-offset-controller.c
index 1c30041..9f46ab0 100644
--- a/src/photos-offset-controller.c
+++ b/src/photos-offset-controller.c
@@ -270,7 +270,7 @@ void
 photos_offset_controller_reset_count (PhotosOffsetController *self)
 {
   PhotosOffsetControllerPrivate *priv;
-  PhotosQuery *query;
+  PhotosQuery *query = NULL;
   const gchar *type_name;
   gchar *tag = NULL;
 
@@ -292,9 +292,9 @@ photos_offset_controller_reset_count (PhotosOffsetController *self)
                                photos_offset_controller_reset_count_query_executed,
                                g_object_ref (self),
                                g_object_unref);
-  photos_query_free (query);
 
  out:
+  g_clear_object (&query);
   g_free (tag);
 }
 
diff --git a/src/photos-properties-dialog.c b/src/photos-properties-dialog.c
index 07af96e..6e8c81f 100644
--- a/src/photos-properties-dialog.c
+++ b/src/photos-properties-dialog.c
@@ -513,7 +513,7 @@ photos_properties_dialog_constructed (GObject *object)
   location = photos_base_item_get_location (item);
   if (location != NULL && location[0] != '\0' && G_LIKELY (self->queue != NULL))
     {
-      PhotosQuery *query;
+      PhotosQuery *query = NULL;
 
       self->location_w = gtk_label_new (_("Location"));
       gtk_widget_set_halign (self->location_w, GTK_ALIGN_END);
@@ -529,7 +529,7 @@ photos_properties_dialog_constructed (GObject *object)
                                    g_object_ref (self),
                                    g_object_unref);
 
-      photos_query_free (query);
+      g_object_unref (query);
     }
 
   equipment = photos_base_item_get_equipment (item);
diff --git a/src/photos-query.c b/src/photos-query.c
index 869fef0..8504070 100644
--- a/src/photos-query.c
+++ b/src/photos-query.c
@@ -30,44 +30,183 @@
 #include "photos-utils.h"
 
 
+struct _PhotosQuery
+{
+  GObject parent_instance;
+  PhotosSearchContextState *state;
+  PhotosSource *source;
+  gchar *sparql;
+  gchar *tag;
+};
+
+enum
+{
+  PROP_0,
+  PROP_SPARQL,
+  PROP_STATE
+};
+
+
+G_DEFINE_TYPE (PhotosQuery, photos_query, G_TYPE_OBJECT);
+
+
 const gchar *PHOTOS_QUERY_COLLECTIONS_IDENTIFIER = "photos:collection:";
 const gchar *PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER = "photos:collection:local:";
 
 
-PhotosQuery *
-photos_query_new (PhotosSearchContextState *state, const gchar *sparql)
+static void
+photos_query_constructed (GObject *object)
 {
-  PhotosQuery *query;
+  PhotosQuery *self = PHOTOS_QUERY (object);
 
-  query = g_slice_new0 (PhotosQuery);
+  G_OBJECT_CLASS (photos_query_parent_class)->constructed (object);
 
-  if (state != NULL)
+  if (self->state != NULL)
     {
-      GObject *active_object;
+      PhotosSource *source;
 
-      active_object = photos_base_manager_get_active_object (state->src_mngr);
-      if (active_object != NULL)
-        query->source = PHOTOS_SOURCE (g_object_ref (active_object));
+      source = PHOTOS_SOURCE (photos_base_manager_get_active_object (self->state->src_mngr));
+      g_set_object (&self->source, source);
     }
 
-  query->sparql = g_strdup (sparql);
+  self->state = NULL; /* We will not need it any more */
+}
+
+
+static void
+photos_query_dispose (GObject *object)
+{
+  PhotosQuery *self = PHOTOS_QUERY (object);
 
-  return query;
+  g_clear_object (&self->source);
+
+  G_OBJECT_CLASS (photos_query_parent_class)->dispose (object);
 }
 
 
-void
-photos_query_set_tag (PhotosQuery *query, const gchar *tag)
+static void
+photos_query_finalize (GObject *object)
+{
+  PhotosQuery *self = PHOTOS_QUERY (object);
+
+  g_free (self->sparql);
+  g_free (self->tag);
+
+  G_OBJECT_CLASS (photos_query_parent_class)->finalize (object);
+}
+
+
+static void
+photos_query_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+  PhotosQuery *self = PHOTOS_QUERY (object);
+
+  switch (prop_id)
+    {
+    case PROP_SPARQL:
+      g_value_set_string (value, self->sparql);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_query_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+  PhotosQuery *self = PHOTOS_QUERY (object);
+
+  switch (prop_id)
+    {
+    case PROP_SPARQL:
+      self->sparql = g_value_dup_string (value);
+      break;
+
+    case PROP_STATE:
+      self->state = (PhotosSearchContextState *) g_value_get_pointer (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+static void
+photos_query_init (PhotosQuery *self)
+{
+}
+
+
+static void
+photos_query_class_init (PhotosQueryClass *class)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+  object_class->constructed = photos_query_constructed;
+  object_class->dispose = photos_query_dispose;
+  object_class->finalize = photos_query_finalize;
+  object_class->get_property = photos_query_get_property;
+  object_class->set_property = photos_query_set_property;
+
+  g_object_class_install_property (object_class,
+                                   PROP_SPARQL,
+                                   g_param_spec_string ("sparql",
+                                                        "SPARQL",
+                                                        "A SPARQL query that's meant to be sent to Tracker",
+                                                        NULL,
+                                                        G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class,
+                                   PROP_STATE,
+                                   g_param_spec_pointer ("state",
+                                                         "State",
+                                                         "The PhotosSearchContextState for this query",
+                                                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+}
+
+
+PhotosQuery *
+photos_query_new (PhotosSearchContextState *state, const gchar *sparql)
+{
+  g_return_val_if_fail (sparql != NULL && sparql[0] != '\0', NULL);
+  return g_object_new (PHOTOS_TYPE_QUERY, "state", state, "sparql", sparql, NULL);
+}
+
+
+const gchar *
+photos_query_get_sparql (PhotosQuery *self)
 {
-  photos_utils_set_string (&query->tag, tag);
+  g_return_val_if_fail (PHOTOS_IS_QUERY (self), NULL);
+  return self->sparql;
+}
+
+
+PhotosSource *
+photos_query_get_source (PhotosQuery *self)
+{
+  g_return_val_if_fail (PHOTOS_IS_QUERY (self), NULL);
+  return self->source;
+}
+
+
+const gchar *
+photos_query_get_tag (PhotosQuery *self)
+{
+  g_return_val_if_fail (PHOTOS_IS_QUERY (self), NULL);
+  return self->tag;
 }
 
 
 void
-photos_query_free (PhotosQuery *query)
+photos_query_set_tag (PhotosQuery *self, const gchar *tag)
 {
-  g_clear_object (&query->source);
-  g_free (query->sparql);
-  g_free (query->tag);
-  g_slice_free (PhotosQuery, query);
+  g_return_if_fail (PHOTOS_IS_QUERY (self));
+  g_return_if_fail (tag != NULL && tag[0] != '\0');
+
+  photos_utils_set_string (&self->tag, tag);
 }
diff --git a/src/photos-query.h b/src/photos-query.h
index 6bc14e2..e895788 100644
--- a/src/photos-query.h
+++ b/src/photos-query.h
@@ -25,13 +25,16 @@
 #ifndef PHOTOS_QUERY_H
 #define PHOTOS_QUERY_H
 
-#include <glib.h>
+#include <glib-object.h>
 
 #include "photos-search-context.h"
 #include "photos-source.h"
 
 G_BEGIN_DECLS
 
+#define PHOTOS_TYPE_QUERY (photos_query_get_type ())
+G_DECLARE_FINAL_TYPE (PhotosQuery, photos_query, PHOTOS, QUERY, GObject);
+
 typedef enum
 {
   PHOTOS_QUERY_COLUMNS_URN,
@@ -72,20 +75,15 @@ typedef enum
 extern const gchar *PHOTOS_QUERY_COLLECTIONS_IDENTIFIER;
 extern const gchar *PHOTOS_QUERY_LOCAL_COLLECTIONS_IDENTIFIER;
 
-typedef struct _PhotosQuery PhotosQuery;
+PhotosQuery     *photos_query_new           (PhotosSearchContextState *state, const gchar *sparql);
 
-struct _PhotosQuery
-{
-  PhotosSource *source;
-  gchar *sparql;
-  gchar *tag;
-};
+const gchar     *photos_query_get_sparql    (PhotosQuery *self);
 
-PhotosQuery    *photos_query_new     (PhotosSearchContextState *state, const gchar *sparql);
+PhotosSource    *photos_query_get_source    (PhotosQuery *self);
 
-void            photos_query_set_tag (PhotosQuery *query, const gchar *tag);
+const gchar     *photos_query_get_tag       (PhotosQuery *self);
 
-void            photos_query_free    (PhotosQuery *query);
+void             photos_query_set_tag       (PhotosQuery *self, const gchar *tag);
 
 G_END_DECLS
 
diff --git a/src/photos-set-collection-job.c b/src/photos-set-collection-job.c
index d4280ee..f634ce1 100644
--- a/src/photos-set-collection-job.c
+++ b/src/photos-set-collection-job.c
@@ -234,7 +234,7 @@ photos_set_collection_job_run (PhotosSetCollectionJob *self,
   urns = photos_selection_controller_get_selection (self->sel_cntrlr);
   for (l = urns; l != NULL; l = l->next)
     {
-      PhotosQuery *query;
+      PhotosQuery *query = NULL;
       const gchar *urn = (gchar *) l->data;
 
       if (g_strcmp0 (self->collection_urn, urn) == 0)
@@ -248,6 +248,6 @@ photos_set_collection_job_run (PhotosSetCollectionJob *self,
                                    photos_set_collection_job_query_executed,
                                    g_object_ref (self),
                                    g_object_unref);
-      photos_query_free (query);
+      g_object_unref (query);
     }
 }
diff --git a/src/photos-single-item-job.c b/src/photos-single-item-job.c
index 5d1b177..63dc337 100644
--- a/src/photos-single-item-job.c
+++ b/src/photos-single-item-job.c
@@ -205,7 +205,7 @@ photos_single_item_job_run (PhotosSingleItemJob *self,
                             gpointer user_data)
 {
   GTask *task;
-  PhotosQuery *query;
+  PhotosQuery *query = NULL;
 
   task = g_task_new (self, cancellable, callback, user_data);
   g_task_set_source_tag (task, photos_single_item_job_run);
@@ -223,8 +223,8 @@ photos_single_item_job_run (PhotosSingleItemJob *self,
                                photos_single_item_job_query_executed,
                                g_object_ref (task),
                                g_object_unref);
-  photos_query_free (query);
 
  out:
+  g_clear_object (&query);
   g_object_unref (task);
 }
diff --git a/src/photos-tracker-change-monitor.c b/src/photos-tracker-change-monitor.c
index 9cacd43..8eac40d 100644
--- a/src/photos-tracker-change-monitor.c
+++ b/src/photos-tracker-change-monitor.c
@@ -289,7 +289,7 @@ photos_tracker_change_monitor_process_events (PhotosTrackerChangeMonitor *self)
                                NULL);
 
   g_string_free (sparql, TRUE);
-  photos_query_free (query);
+  g_object_unref (query);
   return G_SOURCE_REMOVE;
 }
 
diff --git a/src/photos-tracker-controller.c b/src/photos-tracker-controller.c
index 9090340..59f7207 100644
--- a/src/photos-tracker-controller.c
+++ b/src/photos-tracker-controller.c
@@ -281,9 +281,7 @@ photos_tracker_controller_perform_current_query (PhotosTrackerController *self)
 
   priv = photos_tracker_controller_get_instance_private (self);
 
-  if (priv->current_query != NULL)
-    photos_query_free (priv->current_query);
-
+  g_clear_object (&priv->current_query);
   priv->current_query = PHOTOS_TRACKER_CONTROLLER_GET_CLASS (self)->get_query (self);
   g_return_if_fail (priv->current_query != NULL);
 
@@ -384,14 +382,16 @@ static void
 photos_tracker_controller_refresh_for_source (PhotosTrackerController *self)
 {
   PhotosTrackerControllerPrivate *priv;
+  PhotosSource *source;
 
   priv = photos_tracker_controller_get_instance_private (self);
 
-  if (priv->current_query->source != NULL)
+  source = photos_query_get_source (priv->current_query);
+  if (source != NULL)
     {
       const gchar *id;
 
-      id = photos_filterable_get_id (PHOTOS_FILTERABLE (priv->current_query->source));
+      id = photos_filterable_get_id (PHOTOS_FILTERABLE (source));
       if (g_strcmp0 (id, PHOTOS_SOURCE_STOCK_ALL) == 0)
         photos_tracker_controller_refresh_internal (self, PHOTOS_TRACKER_REFRESH_FLAGS_NONE);
     }
@@ -479,6 +479,7 @@ photos_tracker_controller_dispose (GObject *object)
 
   g_clear_object (&priv->src_mngr);
   g_clear_object (&priv->offset_cntrlr);
+  g_clear_object (&priv->current_query);
   g_clear_object (&priv->queue);
 
   G_OBJECT_CLASS (photos_tracker_controller_parent_class)->dispose (object);
@@ -501,9 +502,6 @@ photos_tracker_controller_finalize (GObject *object)
 
   g_clear_error (&priv->queue_error);
 
-  if (priv->current_query != NULL)
-    photos_query_free (priv->current_query);
-
   G_OBJECT_CLASS (photos_tracker_controller_parent_class)->finalize (object);
 
   EGG_COUNTER_DEC (instances);
diff --git a/src/photos-tracker-queue.c b/src/photos-tracker-queue.c
index ea4b2a9..c2e04ca 100644
--- a/src/photos-tracker-queue.c
+++ b/src/photos-tracker-queue.c
@@ -334,14 +334,21 @@ photos_tracker_queue_select (PhotosTrackerQueue *self,
                              gpointer user_data,
                              GDestroyNotify destroy_data)
 {
+  PhotosSource *source;
   PhotosTrackerQueueData *data;
+  const gchar *sparql;
+  const gchar *tag;
 
   if (cancellable != NULL)
     g_object_ref (cancellable);
 
-  data = photos_tracker_queue_data_new (query->source,
-                                        query->sparql,
-                                        query->tag,
+  source = photos_query_get_source (query);
+  sparql = photos_query_get_sparql (query);
+  tag = photos_query_get_tag (query);
+
+  data = photos_tracker_queue_data_new (source,
+                                        sparql,
+                                        tag,
                                         PHOTOS_TRACKER_QUERY_SELECT,
                                         cancellable,
                                         callback,
@@ -361,14 +368,21 @@ photos_tracker_queue_update (PhotosTrackerQueue *self,
                              gpointer user_data,
                              GDestroyNotify destroy_data)
 {
+  PhotosSource *source;
   PhotosTrackerQueueData *data;
+  const gchar *sparql;
+  const gchar *tag;
 
   if (cancellable != NULL)
     g_object_ref (cancellable);
 
-  data = photos_tracker_queue_data_new (query->source,
-                                        query->sparql,
-                                        query->tag,
+  source = photos_query_get_source (query);
+  sparql = photos_query_get_sparql (query);
+  tag = photos_query_get_tag (query);
+
+  data = photos_tracker_queue_data_new (source,
+                                        sparql,
+                                        tag,
                                         PHOTOS_TRACKER_QUERY_UPDATE,
                                         cancellable,
                                         callback,
@@ -388,14 +402,21 @@ photos_tracker_queue_update_blank (PhotosTrackerQueue *self,
                                    gpointer user_data,
                                    GDestroyNotify destroy_data)
 {
+  PhotosSource *source;
   PhotosTrackerQueueData *data;
+  const gchar *sparql;
+  const gchar *tag;
 
   if (cancellable != NULL)
     g_object_ref (cancellable);
 
-  data = photos_tracker_queue_data_new (query->source,
-                                        query->sparql,
-                                        query->tag,
+  source = photos_query_get_source (query);
+  sparql = photos_query_get_sparql (query);
+  tag = photos_query_get_tag (query);
+
+  data = photos_tracker_queue_data_new (source,
+                                        sparql,
+                                        tag,
                                         PHOTOS_TRACKER_QUERY_UPDATE_BLANK,
                                         cancellable,
                                         callback,
diff --git a/src/photos-update-mtime-job.c b/src/photos-update-mtime-job.c
index 93fa1d1..799e5d3 100644
--- a/src/photos-update-mtime-job.c
+++ b/src/photos-update-mtime-job.c
@@ -168,7 +168,7 @@ photos_update_mtime_job_run (PhotosUpdateMtimeJob *self,
 {
   GApplication *app;
   GTask *task;
-  PhotosQuery *query;
+  PhotosQuery *query = NULL;
   PhotosSearchContextState *state;
 
   task = g_task_new (self, cancellable, callback, user_data);
@@ -190,8 +190,8 @@ photos_update_mtime_job_run (PhotosUpdateMtimeJob *self,
                                photos_update_mtime_job_query_executed,
                                g_object_ref (task),
                                g_object_unref);
-  photos_query_free (query);
 
  out:
+  g_clear_object (&query);
   g_object_unref (task);
 }
diff --git a/src/photos-utils.c b/src/photos-utils.c
index b5afbe8..d48bb18 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -1334,8 +1334,8 @@ photos_utils_set_edited_name (const gchar *urn, const gchar *title)
   photos_tracker_queue_update (queue, query, NULL, photos_utils_update_executed, g_strdup (urn), g_free);
 
  out:
+  g_clear_object (&query);
   g_clear_object (&queue);
-  g_clear_pointer (&query, (GDestroyNotify) photos_query_free);
   g_free (sparql);
 }
 
@@ -1366,8 +1366,8 @@ photos_utils_set_favorite (const gchar *urn, gboolean is_favorite)
 
  out:
   g_free (sparql);
+  g_clear_object (&query);
   g_clear_object (&queue);
-  g_clear_pointer (&query, (GDestroyNotify) photos_query_free);
 }
 
 


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