[network-manager-applet/NMA_0_8_1] editor: handle dispose during permissions call (rh #603566)
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/NMA_0_8_1] editor: handle dispose during permissions call (rh #603566)
- Date: Mon, 28 Jun 2010 23:34:16 +0000 (UTC)
commit 0d9a1ec1baa734187d1521ff213c11ddf6dcb3b1
Author: Dan Williams <dcbw redhat com>
Date: Mon Jun 28 16:33:28 2010 -0700
editor: handle dispose during permissions call (rh #603566)
src/connection-editor/ce-polkit-button.c | 35 +++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/src/connection-editor/ce-polkit-button.c b/src/connection-editor/ce-polkit-button.c
index 533edc4..d9c5efc 100644
--- a/src/connection-editor/ce-polkit-button.c
+++ b/src/connection-editor/ce-polkit-button.c
@@ -46,6 +46,7 @@ typedef struct {
NMRemoteSettingsSystem *settings;
NMSettingsSystemPermissions permission;
gboolean use_polkit;
+ GSList *perm_calls;
/* authorized = TRUE if either explicitly authorized or if the action
* could be performed if the user successfully authenticated to gain the
* authorization.
@@ -147,16 +148,30 @@ ce_polkit_button_get_authorized (CEPolkitButton *self)
return CE_POLKIT_BUTTON_GET_PRIVATE (self)->authorized;
}
+typedef struct {
+ CEPolkitButton *self;
+ gboolean disposed;
+} PermInfo;
+
static void
get_permissions_cb (NMSettingsSystemInterface *settings,
NMSettingsSystemPermissions permissions,
GError *error,
gpointer user_data)
{
- CEPolkitButton *self = CE_POLKIT_BUTTON (user_data);
- CEPolkitButtonPrivate *priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);
+ PermInfo *info = user_data;
+ CEPolkitButton *self = info->self;
+ CEPolkitButtonPrivate *priv;
gboolean old_actionable, old_authorized;
+ /* Response might come when button is already disposed */
+ if (info->disposed)
+ goto out;
+
+ priv = CE_POLKIT_BUTTON_GET_PRIVATE (info->self);
+
+ priv->perm_calls = g_slist_remove (priv->perm_calls, info);
+
old_actionable = ce_polkit_button_get_actionable (self);
old_authorized = priv->authorized;
@@ -166,15 +181,23 @@ get_permissions_cb (NMSettingsSystemInterface *settings,
if (priv->authorized != old_authorized)
g_signal_emit (self, signals[AUTHORIZED], 0, priv->authorized);
+
+out:
+ g_free (info);
}
static void
check_permissions_cb (NMRemoteSettingsSystem *settings, CEPolkitButton *self)
{
+ PermInfo *info;
+
+ info = g_malloc0 (sizeof (PermInfo));
+ info->self = self;
+
/* recheck permissions */
nm_settings_system_interface_get_permissions (NM_SETTINGS_SYSTEM_INTERFACE (settings),
get_permissions_cb,
- self);
+ info);
}
GtkWidget *
@@ -225,6 +248,7 @@ static void
dispose (GObject *object)
{
CEPolkitButtonPrivate *priv = CE_POLKIT_BUTTON_GET_PRIVATE (object);
+ GSList *iter;
if (priv->disposed) {
g_warning ("%s: CEPolkitButton object %p disposed twice", __func__, object);
@@ -234,6 +258,11 @@ dispose (GObject *object)
priv->disposed = TRUE;
+ /* Mark any ongoing permissions calls as disposed */
+ for (iter = priv->perm_calls; iter; iter = g_slist_next (iter))
+ ((PermInfo *) iter->data)->disposed = TRUE;
+ g_slist_free (priv->perm_calls);
+
if (priv->check_id)
g_signal_handler_disconnect (priv->settings, priv->check_id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]