summaryrefslogtreecommitdiff
path: root/libnm-glib
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-02-28 12:44:20 -0600
committerDan Williams <dcbw@redhat.com>2012-02-28 12:47:04 -0600
commitaef4340ec4ff2899de8d57903c27e437b5dd4440 (patch)
tree7bc9bc245ad7597d73e7fe9a294ec2a17fd414ee /libnm-glib
parent6fe615bef5f787638679b38bc199b33b4fae73c8 (diff)
downloadNetworkManager-aef4340ec4ff2899de8d57903c27e437b5dd4440.tar.gz
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.
Diffstat (limited to 'libnm-glib')
-rw-r--r--libnm-glib/nm-device.c10
1 files changed, 9 insertions, 1 deletions
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