Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2012-04-16 21:24:20 (GMT)
committer Daniel Drake <dsd@laptop.org>2012-04-16 21:24:20 (GMT)
commit080c3eaf5f7011f975d5670e937deadaa2f84367 (patch)
tree284aceaad241cf22de04ae4dba94e1f08e23c369
parentd12a40da7c3ae575d8afbc78ab591f75f9392e0b (diff)
Prevent handling network devices twice (OLPC#11782)
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 <dsd@laptop.org>
-rw-r--r--extensions/deviceicon/network.py3
-rw-r--r--src/jarabe/desktop/meshbox.py5
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)