From aef4340ec4ff2899de8d57903c27e437b5dd4440 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 28 Feb 2012 12:44:20 -0600 Subject: [PATCH] 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. --- libnm-glib/nm-device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c index 911af7c734..6b3680eb95 100644 --- a/libnm-glib/nm-device.c +++ b/libnm-glib/nm-device.c @@ -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