From 9082631642b84270f4825bcf420eb7447b0fc91e Mon Sep 17 00:00:00 2001
From: Martin Abente <mabente@paraguayeduca.org>
Date: Wed, 9 Jun 2010 16:31:29 -0400
Subject: [PATCH] Fix duplication of OLPC mesh icons
Organization: Paraguay Educa
Three or more mesh icons were being added after every suspend/resume.
There was already code present to detect when the device goes away and
remove the icons, but it was not working. NetworkManagerObserver was
attempting to look at the properties of the gone-away device in order to
see if it is a mesh device, but this was failing because the device has
already been destroyed at this point.
Solve this by recording the device path of the mesh device when it is
detected, so that we can later determine if the gone-away device is the
mesh device.
Signed-off-by: Martin Abente <mabente@paraguayeduca.org>
---
src/jarabe/desktop/meshbox.py | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/jarabe/desktop/meshbox.py b/src/jarabe/desktop/meshbox.py
index a04922b..eabc737 100644
a
|
b
|
class OlpcMeshView(CanvasPulsingIcon): |
574 | 574 | self._update_color() |
575 | 575 | |
576 | 576 | def disconnect(self): |
| 577 | device_object_path = self._mesh_mgr.mesh_device.object_path |
| 578 | |
577 | 579 | self._bus.remove_signal_receiver(self.__device_state_changed_cb, |
578 | 580 | signal_name='StateChanged', |
579 | | path=self._device.object_path, |
| 581 | path=device_object_path, |
580 | 582 | dbus_interface=_NM_DEVICE_IFACE) |
581 | 583 | self._bus.remove_signal_receiver(self.__wireless_properties_changed_cb, |
582 | 584 | signal_name='PropertiesChanged', |
583 | | path=self._device.object_path, |
| 585 | path=device_object_path, |
584 | 586 | dbus_interface=_NM_OLPC_MESH_IFACE) |
585 | 587 | |
586 | 588 | |
… |
… |
class NetworkManagerObserver(object): |
821 | 823 | self._bus = None |
822 | 824 | self._devices = {} |
823 | 825 | self._netmgr = None |
| 826 | self._olpc_mesh_device_o = None |
824 | 827 | |
825 | 828 | def listen(self): |
826 | 829 | try: |
… |
… |
class NetworkManagerObserver(object): |
885 | 888 | if device_type == network.DEVICE_TYPE_802_11_WIRELESS: |
886 | 889 | self._devices[device_o] = DeviceObserver(self._box, device) |
887 | 890 | elif device_type == network.DEVICE_TYPE_802_11_OLPC_MESH: |
| 891 | self._olpc_mesh_device_o = device_o |
888 | 892 | self._box.enable_olpc_mesh(device) |
889 | 893 | |
890 | 894 | def _get_device_path_error_cb(self, err): |
… |
… |
class NetworkManagerObserver(object): |
899 | 903 | observer.disconnect() |
900 | 904 | del self._devices[device_o] |
901 | 905 | return |
902 | | |
903 | | device = self._bus.get_object(_NM_SERVICE, device_o) |
904 | | props = dbus.Interface(device, 'org.freedesktop.DBus.Properties') |
905 | | device_type = props.Get(_NM_DEVICE_IFACE, 'DeviceType') |
906 | | if device_type == network.DEVICE_TYPE_802_11_OLPC_MESH: |
907 | | self._box.disable_olpc_mesh(device) |
| 906 | |
| 907 | if self._olpc_mesh_device_o == device_o: |
| 908 | self._box.disable_olpc_mesh(device_o) |
908 | 909 | |
909 | 910 | class MeshBox(gtk.VBox): |
910 | 911 | __gtype_name__ = 'SugarMeshBox' |