[gnome-control-center/gnome-3-6] background: Fix crash when exiting panel too quickly



commit e3a42c6ba87e4fe28479dd3bd65cdde22208f199
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Oct 17 09:38:05 2012 +0200

    background: Fix crash when exiting panel too quickly
    
    The background capture would still be on-going, and we would
    crash poking at the now gone panel.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=866973

 panels/background/cc-background-panel.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c
index f57ac62..faa14d7 100644
--- a/panels/background/cc-background-panel.c
+++ b/panels/background/cc-background-panel.c
@@ -61,6 +61,7 @@ struct _CcBackgroundPanelPrivate
   CcBackgroundItem *current_background;
 
   GCancellable *copy_cancellable;
+  GCancellable *capture_cancellable;
 
   GtkWidget *spinner;
 
@@ -97,6 +98,15 @@ cc_background_panel_dispose (GObject *object)
       priv->copy_cancellable = NULL;
     }
 
+  if (priv->capture_cancellable)
+    {
+      /* cancel screenshot operations */
+      g_cancellable_cancel (priv->capture_cancellable);
+
+      g_object_unref (priv->capture_cancellable);
+      priv->capture_cancellable = NULL;
+    }
+
   g_clear_object (&priv->thumb_factory);
   g_clear_object (&priv->display_screenshot);
 
@@ -242,6 +252,10 @@ on_screenshot_finished (GObject *source,
                                  &error);
 
   if (error != NULL) {
+    if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+      g_error_free (error);
+      return;
+    }
     g_debug ("Unable to get screenshot: %s",
              error->message);
     g_error_free (error);
@@ -332,7 +346,7 @@ get_screenshot_async (CcBackgroundPanel *panel,
                           NULL,
                           G_DBUS_CALL_FLAGS_NONE,
                           -1,
-                          NULL,
+                          priv->capture_cancellable,
                           on_screenshot_finished,
                           panel);
 }
@@ -709,6 +723,7 @@ cc_background_panel_init (CcBackgroundPanel *self)
                     self);
 
   priv->copy_cancellable = g_cancellable_new ();
+  priv->capture_cancellable = g_cancellable_new ();
 
   priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
 



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