Commit aef4340e authored by Dan Williams's avatar Dan Williams

libnm-glib: ensure device state is updated when it changes

NM emits coalesced PropertiesChanged signals, which might be
delayed slightly and thus sent after the StateChanged signal
for devices.  Clients of libnm-glib listening for the
'state-changed' signal and then querying the state manually
using nm_device_get_state() would still see the old state until
it was updated via the delayed PropertiesChanged signal
processing.  Since when the StateChanged signal comes in the
device is already in the new state, just update the state and
leave the GObject property notify signal to the
PropertiesChanged signal handling code so that clients have
an accurate device state.
parent 6fe615be
......@@ -182,8 +182,16 @@ device_state_changed (DBusGProxy *proxy,
NMDevice *self = NM_DEVICE (user_data);
if (old_state != new_state)
if (old_state != new_state) {
/* Update state here since the PropertyChanged signal for state
* might come in a bit later, but a client might ask for the
* state via nm_device_get_state() as a result of this signal.
* When the PC signal does come in that will trigger the glib
* property notify signal so we don't need to do that here.
NM_DEVICE_GET_PRIVATE (self)->state = new_state;
g_signal_emit (self, signals[STATE_CHANGED], 0, new_state, old_state, reason);
static void
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