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
This commit is contained in:
Bastien Nocera 2012-10-17 09:38:05 +02:00
parent e06657e7da
commit 0d9fd1005f

View file

@ -61,6 +61,7 @@ struct _CcBackgroundPanelPrivate
CcBackgroundItem *current_background; CcBackgroundItem *current_background;
GCancellable *copy_cancellable; GCancellable *copy_cancellable;
GCancellable *capture_cancellable;
GtkWidget *spinner; GtkWidget *spinner;
@ -97,6 +98,15 @@ cc_background_panel_dispose (GObject *object)
priv->copy_cancellable = NULL; 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->thumb_factory);
g_clear_object (&priv->display_screenshot); g_clear_object (&priv->display_screenshot);
@ -247,6 +257,10 @@ on_screenshot_finished (GObject *source,
&error); &error);
if (error != NULL) { 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", g_debug ("Unable to get screenshot: %s",
error->message); error->message);
g_error_free (error); g_error_free (error);
@ -376,7 +390,7 @@ get_screenshot_async (CcBackgroundPanel *panel)
NULL, NULL,
G_DBUS_CALL_FLAGS_NONE, G_DBUS_CALL_FLAGS_NONE,
-1, -1,
NULL, priv->capture_cancellable,
on_screenshot_finished, on_screenshot_finished,
data); data);
} }
@ -748,6 +762,7 @@ cc_background_panel_init (CcBackgroundPanel *self)
self); self);
priv->copy_cancellable = g_cancellable_new (); 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); priv->thumb_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);