mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 01:50:25 +01:00
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
This commit is contained in:
parent
3f4811be22
commit
ffa012f3ce
1 changed files with 13 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue