[network-manager-applet] editor: fix PolicyKit button refcounting
- From: Dan Williams <dcbw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-applet] editor: fix PolicyKit button refcounting
- Date: Mon, 21 Sep 2009 20:31:17 +0000 (UTC)
commit ae143e81bb940c6026ef73acf932cdd94c14da52
Author: Dan Williams <dcbw redhat com>
Date: Mon Sep 21 13:29:33 2009 -0700
editor: fix PolicyKit button refcounting
When creating GTK widgets manually, they start with a floating
reference not a real reference, so we need to convert that
floating ref into a real ref before really using it, or we'll get
duplicate calls to the dispose method. glade usually handles
this behind-the-scenes for us, but when making our own widgets we
have to do that manually.
src/connection-editor/ce-polkit-button.c | 29 +++++++++++++++++++++----
src/connection-editor/nm-connection-editor.c | 1 +
src/connection-editor/nm-connection-list.c | 2 +
3 files changed, 27 insertions(+), 5 deletions(-)
---
diff --git a/src/connection-editor/ce-polkit-button.c b/src/connection-editor/ce-polkit-button.c
index dc2d2a5..f9c1d13 100644
--- a/src/connection-editor/ce-polkit-button.c
+++ b/src/connection-editor/ce-polkit-button.c
@@ -32,6 +32,8 @@ G_DEFINE_TYPE (CEPolkitButton, ce_polkit_button, GTK_TYPE_BUTTON)
#define CE_POLKIT_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CE_TYPE_POLKIT_BUTTON, CEPolkitButtonPrivate))
typedef struct {
+ gboolean disposed;
+
char *label;
char *tooltip;
char *auth_label;
@@ -208,14 +210,17 @@ ce_polkit_button_new (const char *label,
}
static void
-finalize (GObject *object)
+dispose (GObject *object)
{
CEPolkitButtonPrivate *priv = CE_POLKIT_BUTTON_GET_PRIVATE (object);
- g_free (priv->label);
- g_free (priv->auth_label);
- g_free (priv->tooltip);
- g_free (priv->auth_tooltip);
+ if (priv->disposed) {
+ g_warning ("%s: CEPolkitButton object %p disposed twice", __func__, object);
+ G_OBJECT_CLASS (ce_polkit_button_parent_class)->dispose (object);
+ return;
+ }
+
+ priv->disposed = TRUE;
if (priv->check_id)
g_signal_handler_disconnect (priv->settings, priv->check_id);
@@ -224,6 +229,19 @@ finalize (GObject *object)
g_object_unref (priv->auth);
g_object_unref (priv->stock);
+ G_OBJECT_CLASS (ce_polkit_button_parent_class)->dispose (object);
+}
+
+static void
+finalize (GObject *object)
+{
+ CEPolkitButtonPrivate *priv = CE_POLKIT_BUTTON_GET_PRIVATE (object);
+
+ g_free (priv->label);
+ g_free (priv->auth_label);
+ g_free (priv->tooltip);
+ g_free (priv->auth_tooltip);
+
G_OBJECT_CLASS (ce_polkit_button_parent_class)->finalize (object);
}
@@ -239,6 +257,7 @@ ce_polkit_button_class_init (CEPolkitButtonClass *pb_class)
g_type_class_add_private (object_class, sizeof (CEPolkitButtonPrivate));
+ object_class->dispose = dispose;
object_class->finalize = finalize;
signals[ACTIONABLE] = g_signal_new ("actionable",
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index f27c10e..eb96317 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -392,6 +392,7 @@ nm_connection_editor_new (NMConnection *connection,
settings,
NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY);
ce_polkit_button_set_use_polkit (CE_POLKIT_BUTTON (editor->ok_button), use_polkit);
+ g_object_ref_sink (editor->ok_button);
g_signal_connect (editor->ok_button, "actionable",
G_CALLBACK (ok_button_actionable_cb), editor);
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 8268bba..e4c2283 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -1262,6 +1262,7 @@ add_connection_buttons (NMConnectionList *self,
GTK_STOCK_EDIT,
self->system_settings,
NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY);
+ g_object_ref_sink (button);
gtk_box_pack_end (GTK_BOX (hbox), button, TRUE, TRUE, 0);
action_info_set_button (info, button);
@@ -1279,6 +1280,7 @@ add_connection_buttons (NMConnectionList *self,
GTK_STOCK_DELETE,
self->system_settings,
NM_SETTINGS_SYSTEM_PERMISSION_CONNECTION_MODIFY);
+ g_object_ref_sink (button);
gtk_box_pack_end (GTK_BOX (hbox), button, TRUE, TRUE, 0);
action_info_set_button (info, button);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]