[gnome-photos/wip/rishi/thumbnailer: 8/8] base-item: Clean up the mess when photos_base_item_load_async fails



commit 206b7070d4dfa8ea2b40a4f9e3a4cc50f486bdc0
Author: Debarshi Ray <debarshir gnome org>
Date:   Sun Feb 26 13:05:30 2017 +0100

    base-item: Clean up the mess when photos_base_item_load_async fails
    
    Otherwise, the BaseItem is left in an inconsistent state. For example,
    if the photos_base_item_load_async failure was due to a cancellation,
    then subsequent attempts to load the BaseItem might not work.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777867

 src/photos-base-item.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index 5c6f12f..713fdd4 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -418,6 +418,22 @@ photos_base_item_check_effects_and_update_info (PhotosBaseItem *self)
 
 
 static void
+photos_base_item_clear_pixels (PhotosBaseItem *self)
+{
+  PhotosBaseItemPrivate *priv;
+
+  priv = photos_base_item_get_instance_private (self);
+
+  priv->buffer_source = NULL;
+
+  g_clear_object (&priv->edit_graph);
+  g_clear_object (&priv->pipeline);
+  g_clear_object (&priv->preview_source_buffer);
+  g_clear_object (&priv->processor);
+}
+
+
+static void
 photos_base_item_set_original_icon (PhotosBaseItem *self, GdkPixbuf *icon)
 {
   PhotosBaseItemPrivate *priv;
@@ -1458,6 +1474,7 @@ photos_base_item_load_process (GObject *source_object, GAsyncResult *res, gpoint
   photos_base_item_process_finish (self, res, &error);
   if (error != NULL)
     {
+      photos_base_item_clear_pixels (self);
       g_task_return_error (task, error);
       goto out;
     }
@@ -1491,6 +1508,7 @@ photos_base_item_load_load_buffer (GObject *source_object, GAsyncResult *res, gp
   buffer = photos_base_item_load_buffer_finish (self, res, &error);
   if (error != NULL)
     {
+      photos_base_item_clear_pixels (self);
       g_task_return_error (task, error);
       goto out;
     }
@@ -1528,6 +1546,7 @@ photos_base_item_load_pipeline (GObject *source_object, GAsyncResult *res, gpoin
   priv->pipeline = photos_pipeline_new_finish (res, &error);
   if (error != NULL)
     {
+      photos_base_item_clear_pixels (self);
       g_task_return_error (task, error);
       goto out;
     }
@@ -2495,14 +2514,12 @@ photos_base_item_dispose (GObject *object)
        g_clear_object (&priv->cancellable);
     }
 
+  photos_base_item_clear_pixels (self);
+
   g_clear_pointer (&priv->surface, (GDestroyNotify) cairo_surface_destroy);
   g_clear_object (&priv->default_app);
-  g_clear_object (&priv->preview_source_buffer);
-  g_clear_object (&priv->edit_graph);
-  g_clear_object (&priv->processor);
   g_clear_object (&priv->original_icon);
   g_clear_object (&priv->watcher);
-  g_clear_object (&priv->pipeline);
   g_clear_object (&priv->sel_cntrlr);
   g_clear_object (&priv->cursor);
 


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