Commit db6e8b21 authored by Lubomir Rintel's avatar Lubomir Rintel 🥕 Committed by Thomas Haller

active-connection: drop off the bus when the settings connection disappears

The active connection has an immutable connection property, but is
cleaned asynchronously by the manager after its settings connection is
done. Fine, let's remove it from the bus first though, so that we don't
hang there with a dangling object path.

(cherry picked from commit f0e3dfda)
parent 701f7928
......@@ -156,6 +156,20 @@ _settings_connection_updated (NMSettingsConnection *connection,
* settings-connection. */
}
static void
_settings_connection_removed (NMSettingsConnection *connection,
gpointer user_data)
{
NMActiveConnection *self = user_data;
/* Our settings connection is about to drop off. The next active connection
* cleanup is going to tear us down (at least until we grow the capability to
* re-link; in that case we'd just clean the references to the old connection here).
* Let's remove ourselves from the bus so that we're not exposed with a dangling
* reference to the setting connection once it's gone. */
nm_exported_object_unexport (NM_EXPORTED_OBJECT (self));
}
static void
_set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connection)
{
......@@ -170,6 +184,7 @@ _set_settings_connection (NMActiveConnection *self, NMSettingsConnection *connec
if (connection) {
priv->settings_connection = g_object_ref (connection);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, (GCallback) _settings_connection_updated, self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED, (GCallback) _settings_connection_removed, self);
}
}
......
......@@ -1112,8 +1112,10 @@ claim_connection (NMSettings *self, NMSettingsConnection *connection)
openconnect_migrate_hack (NM_CONNECTION (connection));
g_object_ref (self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_REMOVED,
G_CALLBACK (connection_removed), self);
/* This one unexports the connection, it needs to run late to give the active
* connection a chance to deal with its reference to this settings connection. */
g_signal_connect_after (connection, NM_SETTINGS_CONNECTION_REMOVED,
G_CALLBACK (connection_removed), self);
g_signal_connect (connection, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL,
G_CALLBACK (connection_updated), self);
g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_VISIBLE,
......
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