Due to the asynchronous way that dbus works, it is possible to receive a network device listed in the initial GetDevices call, and as a DeviceAdded signal, if the device appears during Sugar initialisation.
Check to see that a device is really new before processing it. Fixes a case seen by Manuel and me where two network device icons appear. Signed-off-by: Daniel Drake <d...@laptop.org> --- extensions/deviceicon/network.py | 3 +++ src/jarabe/desktop/meshbox.py | 5 +++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py index 09a3abb..96713fb 100644 --- a/extensions/deviceicon/network.py +++ b/extensions/deviceicon/network.py @@ -1020,6 +1020,9 @@ class NetworkManagerObserver(object): logging.error('Failed to get devices: %s', err) def _check_device(self, device_op): + if device_op in self._devices: + return + nm_device = self._bus.get_object(network.NM_SERVICE, device_op) props = dbus.Interface(nm_device, dbus.PROPERTIES_IFACE) diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py index 0d0c9c1..20dc413 100644 --- a/src/jarabe/desktop/meshbox.py +++ b/src/jarabe/desktop/meshbox.py @@ -350,6 +350,8 @@ class NetworkManagerObserver(object): device_type = props.Get(network.NM_DEVICE_IFACE, 'DeviceType') if device_type == network.NM_DEVICE_TYPE_WIFI: + if device_o in self._devices: + return self._devices[device_o] = DeviceObserver(device) self._devices[device_o].connect('access-point-added', self.__ap_added_cb) @@ -358,6 +360,8 @@ class NetworkManagerObserver(object): if self._have_adhoc_networks: self._box.add_adhoc_networks(device) elif device_type == network.NM_DEVICE_TYPE_OLPC_MESH: + if device_o == self._olpc_mesh_device_o: + return self._olpc_mesh_device_o = device_o self._box.enable_olpc_mesh(device) @@ -378,6 +382,7 @@ class NetworkManagerObserver(object): if self._olpc_mesh_device_o == device_o: self._box.disable_olpc_mesh(device_o) + self._olpc_mesh_device_o = None def __ap_added_cb(self, device_observer, access_point): self._box.add_access_point(device_observer.device, access_point) -- 1.7.7.6 _______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel