[gnome-control-center/gnome-3-8] region: Cancel any async operations with callbacks on finalize
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-3-8] region: Cancel any async operations with callbacks on finalize
- Date: Thu, 14 Mar 2013 16:00:39 +0000 (UTC)
commit be5683c40151e5d924e4192ebd8068875ba8b92b
Author: Rui Matos <tiagomatos gmail com>
Date: Thu Mar 14 11:19:20 2013 +0100
region: Cancel any async operations with callbacks on finalize
Otherwise we may end up using a finalized "object" in the callbacks.
https://bugzilla.gnome.org/show_bug.cgi?id=695534
panels/region/cc-region-panel.c | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index c85c1df..1b53dc5 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -83,6 +83,7 @@ struct _CcRegionPanelPrivate {
GPermission *permission;
SystemOp op;
GDBusProxy *localed;
+ GCancellable *cancellable;
GtkWidget *overlay;
GtkWidget *notification;
@@ -127,6 +128,9 @@ cc_region_panel_finalize (GObject *object)
CcRegionPanel *self = CC_REGION_PANEL (object);
CcRegionPanelPrivate *priv = self->priv;
+ g_cancellable_cancel (priv->cancellable);
+ g_clear_object (&priv->cancellable);
+
if (priv->user_manager) {
g_signal_handlers_disconnect_by_data (priv->user_manager, self);
priv->user_manager = NULL;
@@ -1510,17 +1514,22 @@ localed_proxy_ready (GObject *source,
gpointer data)
{
CcRegionPanel *self = data;
- CcRegionPanelPrivate *priv = self->priv;
+ CcRegionPanelPrivate *priv;
+ GDBusProxy *proxy;
GError *error = NULL;
- priv->localed = g_dbus_proxy_new_finish (res, &error);
+ proxy = g_dbus_proxy_new_finish (res, &error);
- if (!priv->localed) {
- g_warning ("Failed to contact localed: %s\n", error->message);
+ if (!proxy) {
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
+ g_warning ("Failed to contact localed: %s\n", error->message);
g_error_free (error);
return;
}
+ priv = self->priv;
+ priv->localed = proxy;
+
gtk_widget_set_sensitive (priv->login_button, TRUE);
g_signal_connect (priv->localed, "g-properties-changed",
@@ -1569,7 +1578,7 @@ setup_login_button (CcRegionPanel *self)
"org.freedesktop.locale1",
"/org/freedesktop/locale1",
"org.freedesktop.locale1",
- NULL,
+ priv->cancellable,
(GAsyncReadyCallback) localed_proxy_ready,
self);
g_object_unref (bus);
@@ -1609,6 +1618,8 @@ cc_region_panel_init (CcRegionPanel *self)
priv->user_manager = act_user_manager_get_default ();
+ priv->cancellable = g_cancellable_new ();
+
setup_login_button (self);
setup_language_section (self);
setup_input_section (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]