summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2013-09-09 09:13:41 -0400
committerDan Winship <danw@gnome.org>2013-09-09 09:28:24 -0400
commitffa012f3cef96daead331c6f573e5357d7f0ad85 (patch)
tree444e11bb05dab80d2ea1cef6eb98b2ea04ac97c4
parent3f4811be225a530c5529d54da20efdf72dc50412 (diff)
libnm-glib: fix nm_remote_connection_delete() callback
If you called nm_remote_connection_delete() on a connection whose only ref was held by the NMRemoteSettings, then the callback would never get called, because NMRemoteSettings would drop its ref before then (when the connection emitted the 'removed' signal), so the callback would get cancelled. Fix this by taking an extra ref on the connection around the D-Bus call in this case. https://bugzilla.redhat.com/show_bug.cgi?id=997568 https://bugzilla.gnome.org/show_bug.cgi?id=706141
-rw-r--r--libnm-glib/nm-remote-connection.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libnm-glib/nm-remote-connection.c b/libnm-glib/nm-remote-connection.c
index f72b71e91f..a03a44bf42 100644
--- a/libnm-glib/nm-remote-connection.c
+++ b/libnm-glib/nm-remote-connection.c
@@ -71,6 +71,7 @@ typedef struct {
DBusGProxyCall *call;
GFunc callback;
gpointer user_data;
+ gboolean extra_ref;
} RemoteCall;
typedef struct {
@@ -118,6 +119,10 @@ remote_call_complete (NMRemoteConnection *self, RemoteCall *call)
NMRemoteConnectionPrivate *priv = NM_REMOTE_CONNECTION_GET_PRIVATE (self);
priv->calls = g_slist_remove (priv->calls, call);
+
+ if (call->extra_ref)
+ g_object_unref (self);
+
/* Don't need to cancel it since this function should only be called from
* the dispose handler (where the proxy will be destroyed immediately after)
* or from the call's completion callback.
@@ -286,6 +291,14 @@ nm_remote_connection_delete (NMRemoteConnection *self,
call->callback = (GFunc) callback;
call->user_data = user_data;
+ if (callback) {
+ /* Grab an extra ref on @self to make sure it doesn't get
+ * destroyed by the NMRemoteSettings before the callback runs.
+ */
+ g_object_ref (self);
+ call->extra_ref = TRUE;
+ }
+
call->call = dbus_g_proxy_begin_call (priv->proxy, "Delete",
result_cb, call, NULL,
G_TYPE_INVALID);