diff --git a/panels/background/cc-background-panel.c b/panels/background/cc-background-panel.c index 02c51b0d7..0259aa96f 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); @@ -247,6 +257,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); @@ -376,7 +390,7 @@ get_screenshot_async (CcBackgroundPanel *panel) NULL, G_DBUS_CALL_FLAGS_NONE, -1, - NULL, + priv->capture_cancellable, on_screenshot_finished, data); } @@ -748,6 +762,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);