core: clear device on NMActiveConnection when the connection is DEACTIVATED

This commit is contained in:
Jiří Klimeš 2013-12-03 16:49:21 +01:00 committed by Dan Williams
parent f8da87af32
commit b0fb239df3
2 changed files with 25 additions and 9 deletions

View file

@ -86,6 +86,7 @@ enum {
};
static void check_master_ready (NMActiveConnection *self);
static void _device_cleanup (NMActiveConnectionPrivate *priv);
/****************************************************************/
@ -146,10 +147,11 @@ nm_active_connection_set_state (NMActiveConnection *self,
}
if (priv->state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
/* Device is no longer relevant when deactivated; emit property change
* notification so clients re-read the value, which will be NULL due to
* conditions in get_property().
/* Device is no longer relevant when deactivated. So remove it and
* emit property change notification so clients re-read the value,
* which will be NULL due to conditions in get_property().
*/
_device_cleanup (priv);
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEVICES);
}
}
@ -726,6 +728,17 @@ get_property (GObject *object, guint prop_id,
}
}
static void
_device_cleanup (NMActiveConnectionPrivate *priv)
{
if (priv->device_state_id) {
g_assert (priv->device);
g_signal_handler_disconnect (priv->device, priv->device_state_id);
priv->device_state_id = 0;
}
g_clear_object (&priv->device);
}
static void
dispose (GObject *object)
{
@ -743,12 +756,7 @@ dispose (GObject *object)
g_clear_object (&priv->connection);
if (priv->device_state_id) {
g_assert (priv->device);
g_signal_handler_disconnect (priv->device, priv->device_state_id);
priv->device_state_id = 0;
}
g_clear_object (&priv->device);
_device_cleanup (priv);
if (priv->master) {
g_signal_handlers_disconnect_by_func (priv->master,

View file

@ -206,6 +206,12 @@ nm_vpn_connection_set_vpn_state (NMVPNConnection *connection,
old_vpn_state = priv->vpn_state;
priv->vpn_state = vpn_state;
/* The device gets destroyed by active connection when it enters
* the deactivated state, so we need to ref it for usage below.
*/
if (parent_dev)
g_object_ref (parent_dev);
/* Update active connection base class state */
nm_active_connection_set_state (NM_ACTIVE_CONNECTION (connection),
ac_state_from_vpn_state (vpn_state));
@ -271,6 +277,8 @@ nm_vpn_connection_set_vpn_state (NMVPNConnection *connection,
}
g_object_unref (connection);
if (parent_dev)
g_object_unref (parent_dev);
}
static void