[gnome-photos/wip/rishi/thumbnailer: 13/15] base-item: Use a GCancellable when creating a thumbnail



commit c44ed911087b0b0bc54aba415cdbea8251c69625
Author: Debarshi Ray <debarshir gnome org>
Date:   Wed Feb 22 17:37:57 2017 +0100

    base-item: Use a GCancellable when creating a thumbnail
    
    Ongoing thumbnailing jobs need to be cancelled whenever the pipeline is
    saved so that we can create a new one to reflect the edited state of
    the item.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763329

 src/photos-base-item.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 28319c9..d0d64b1 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -939,17 +939,30 @@ photos_base_item_create_thumbnail_cb (GObject *source_object, GAsyncResult *res,
   PhotosBaseItemPrivate *priv;
   GError *error;
   GFile *file = G_FILE (user_data);
-
-  priv = photos_base_item_get_instance_private (self);
+  gboolean success;
 
   error = NULL;
-  photos_base_item_create_thumbnail_finish (self, res, &error);
+  success = photos_base_item_create_thumbnail_finish (self, res, &error);
   if (error != NULL)
     {
+      if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        {
+          g_error_free (error);
+          goto out;
+        }
+      else
+        {
+          g_warning ("Unable to create thumbnail: %s", error->message);
+          g_error_free (error);
+        }
+    }
+
+  priv = photos_base_item_get_instance_private (self);
+
+  if (!success)
+    {
       priv->failed_thumbnailing = TRUE;
-      g_warning ("Unable to create thumbnail: %s", error->message);
       photos_base_item_set_failed_icon (self);
-      g_error_free (error);
       goto out;
     }
 
@@ -1012,7 +1025,7 @@ photos_base_item_file_query_info (GObject *source_object, GAsyncResult *res, gpo
   else
     {
       photos_base_item_create_thumbnail_async (self,
-                                               NULL,
+                                               priv->cancellable,
                                                photos_base_item_create_thumbnail_cb,
                                                g_object_ref (file));
     }


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