diff --git a/src/nm-activation-request.c b/src/nm-activation-request.c index 88504ce0dd..76949cf279 100644 --- a/src/nm-activation-request.c +++ b/src/nm-activation-request.c @@ -297,6 +297,7 @@ nm_act_request_add_share_rule (NMActRequest *req, static void device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self) { + NMActRequestPrivate *priv = NM_ACT_REQUEST_GET_PRIVATE (self); NMActiveConnectionState ac_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN; /* Set NMActiveConnection state based on the device's state */ @@ -318,6 +319,13 @@ device_state_changed (NMDevice *device, GParamSpec *pspec, NMActRequest *self) case NM_DEVICE_STATE_FAILED: case NM_DEVICE_STATE_DISCONNECTED: ac_state = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED; + + /* No longer need to pay attention to device state */ + if (priv->device && priv->device_state_id) { + g_signal_handler_disconnect (priv->device, priv->device_state_id); + priv->device_state_id = 0; + } + g_clear_object (&priv->device); break; default: break; diff --git a/src/nm-active-connection.c b/src/nm-active-connection.c index 15b4b48553..6e3a5da63c 100644 --- a/src/nm-active-connection.c +++ b/src/nm-active-connection.c @@ -101,6 +101,10 @@ nm_active_connection_set_state (NMActiveConnection *self, if (priv->state == new_state) return; + /* DEACTIVATED is a terminal state */ + if (priv->state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) + g_return_if_fail (new_state != NM_ACTIVE_CONNECTION_STATE_DEACTIVATED); + old_state = priv->state; priv->state = new_state; g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_STATE); @@ -110,6 +114,12 @@ nm_active_connection_set_state (NMActiveConnection *self, nm_settings_connection_update_timestamp (NM_SETTINGS_CONNECTION (priv->connection), (guint64) time (NULL), TRUE); } + + if (priv->state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) { + /* Device is no longer relevant when deactivated */ + g_clear_object (&priv->device); + g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_DEVICES); + } } const char *