[gnome-photos/wip/rishi/edit-mode: 7/14] base-item: Create the GEGL graph from the main thread



commit 7e7dc5f6fa1f579c920d6f7048320f32e5726179
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Jan 29 15:20:22 2015 +0100

    base-item: Create the GEGL graph from the main thread
    
    Creating and destroying the graph from different threads does not look
    like a good idea. This has not caused us any issues so far, but it
    might when the graph becomes less trivial. We can easily avoid this, so
    why not?

 src/photos-base-item.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 80a5aff..321cc2d 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -68,6 +68,7 @@ struct _PhotosBaseItemPrivate
   gboolean collection;
   gboolean failed_thumbnailing;
   gboolean favorite;
+  gboolean loaded_once;
   const gchar *thumb_path;
   gchar *author;
   gchar *default_app_name;
@@ -732,17 +733,14 @@ photos_base_item_load (PhotosBaseItem *self, GCancellable *cancellable, GError *
   GeglNode *ret_val = NULL;
   gchar *path = NULL;
 
-  if (priv->graph == NULL)
+  if (!priv->loaded_once)
     {
       path = photos_base_item_download (self, cancellable, error);
       if (path == NULL)
         goto out;
 
-      priv->graph = gegl_node_new ();
-      priv->node = gegl_node_new_child (priv->graph,
-                                        "operation", "gegl:load",
-                                        "path", path,
-                                        NULL);
+      gegl_node_set (priv->node, "path", path, NULL);
+      priv->loaded_once = TRUE;
     }
 
   gegl_node_process (priv->node);
@@ -1393,10 +1391,17 @@ photos_base_item_load_async (PhotosBaseItem *self,
                              GAsyncReadyCallback callback,
                              gpointer user_data)
 {
+  PhotosBaseItemPrivate *priv = self->priv;
   GTask *task;
 
   g_return_if_fail (PHOTOS_IS_BASE_ITEM (self));
 
+  if (priv->graph == NULL)
+    {
+      priv->graph = gegl_node_new ();
+      priv->node = gegl_node_new_child (priv->graph, "operation", "gegl:load", NULL);
+    }
+
   task = g_task_new (self, cancellable, callback, user_data);
   g_task_set_check_cancellable (task, TRUE);
   g_task_set_source_tag (task, photos_base_item_load_async);


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