[gnome-control-center/gnome-3-8] background: Fix handling of cancellation in async calls



commit cd2495787209cb11492e86ecfbfb1f5505ac4240
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 26 15:43:39 2013 +0100

    background: Fix handling of cancellation in async calls
    
    A few of the async calls were still handling the user_data before
    checking that it was still valid (eg. the operation was not cancelled),
    and also printing warnings when the error was a cancellation.

 panels/background/bg-pictures-source.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c
index 77c9fad..b678e61 100644
--- a/panels/background/bg-pictures-source.c
+++ b/panels/background/bg-pictures-source.c
@@ -371,7 +371,7 @@ file_info_async_ready (GObject      *source,
                        GAsyncResult *res,
                        gpointer      user_data)
 {
-  BgPicturesSource *bg_source = BG_PICTURES_SOURCE (user_data);
+  BgPicturesSource *bg_source;
   GList *files, *l;
   GError *err = NULL;
   GFile *parent;
@@ -381,7 +381,8 @@ file_info_async_ready (GObject      *source,
                                                &err);
   if (err)
     {
-      g_warning ("Could not get pictures file information: %s", err->message);
+      if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        g_warning ("Could not get pictures file information: %s", err->message);
       g_error_free (err);
 
       g_list_foreach (files, (GFunc) g_object_unref, NULL);
@@ -389,6 +390,8 @@ file_info_async_ready (GObject      *source,
       return;
     }
 
+  bg_source = BG_PICTURES_SOURCE (user_data);
+
   parent = g_file_enumerator_get_container (G_FILE_ENUMERATOR (source));
 
   files = g_list_sort (files, file_sort_func);
@@ -413,7 +416,7 @@ dir_enum_async_ready (GObject      *source,
                       GAsyncResult *res,
                       gpointer      user_data)
 {
-  BgPicturesSourcePrivate *priv = BG_PICTURES_SOURCE (user_data)->priv;
+  BgPicturesSourcePrivate *priv;
   GFileEnumerator *enumerator;
   GError *err = NULL;
 
@@ -421,12 +424,15 @@ dir_enum_async_ready (GObject      *source,
 
   if (err)
     {
-      if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) == FALSE)
+      if (!g_error_matches (err, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) &&
+          !g_error_matches (err, G_IO_ERROR, G_IO_ERROR_CANCELLED))
         g_warning ("Could not fill pictures source: %s", err->message);
       g_error_free (err);
       return;
     }
 
+  priv = BG_PICTURES_SOURCE (user_data)->priv;
+
   /* get the files */
   g_file_enumerator_next_files_async (enumerator,
                                       G_MAXINT,
@@ -537,7 +543,8 @@ file_info_ready (GObject      *object,
 
   if (!info)
     {
-      g_warning ("Problem looking up file info: %s", error->message);
+      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+        g_warning ("Problem looking up file info: %s", error->message);
       g_clear_error (&error);
       return;
     }


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