[gnome-photos/wip/rishi/cancel-async: 1/2] preview-view: Cancel pipeline_save_async during destruction



commit b1c4a945e4b9e2aa282a803bfc436f8af24ed0d0
Author: Rafael Fonseca <r4f4rfs gmail com>
Date:   Mon Mar 21 17:32:54 2016 +0100

    preview-view: Cancel pipeline_save_async during destruction
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763908

 src/photos-preview-view.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 28f6f3f..460801c 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -498,7 +498,7 @@ photos_preview_view_tool_changed (PhotosPreviewView *self, PhotosTool *tool)
 static void
 photos_preview_view_edit_done_pipeline_save (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
-  PhotosPreviewView *self = PHOTOS_PREVIEW_VIEW (user_data);
+  PhotosPreviewView *self;
   PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
   GApplication *app;
   GError *error;
@@ -506,11 +506,13 @@ photos_preview_view_edit_done_pipeline_save (GObject *source_object, GAsyncResul
   error = NULL;
   if (!photos_base_item_pipeline_save_finish (item, res, &error))
     {
-      g_warning ("Unable to save pipeline: %s", error->message);
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        g_warning ("Unable to save pipeline: %s", error->message);
       g_error_free (error);
       goto out;
     }
 
+  self = PHOTOS_PREVIEW_VIEW (user_data);
   photos_mode_controller_go_back (self->mode_cntrlr);
 
   photos_done_notification_new (item);
@@ -518,7 +520,6 @@ photos_preview_view_edit_done_pipeline_save (GObject *source_object, GAsyncResul
  out:
   app = g_application_get_default ();
   g_application_release (G_APPLICATION (app));
-  g_object_unref (self);
 }
 
 
@@ -537,9 +538,9 @@ photos_preview_view_edit_done (PhotosPreviewView *self)
   g_application_hold (app);
 
   photos_base_item_pipeline_save_async (item,
-                                        NULL,
+                                        self->cancellable,
                                         photos_preview_view_edit_done_pipeline_save,
-                                        g_object_ref (self));
+                                        self);
 }
 
 


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