Commit 3efb71ba authored by Rui Matos's avatar Rui Matos
Browse files

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
parent e2163ea9
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment