[sugar] [PATCH] adding a bad device to the frame shouldn't crash sugar

Martin Dengler martin
Tue Jun 3 22:56:01 EDT 2008


---
 src/view/frame/devicestray.py |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/view/frame/devicestray.py b/src/view/frame/devicestray.py
index 1accdad..1b7f3d1 100644
--- a/src/view/frame/devicestray.py
+++ b/src/view/frame/devicestray.py
@@ -35,11 +35,17 @@ class DevicesTray(HTray):
                               self.__device_disappeared_cb)
 
     def _add_device(self, device):
-        view = deviceview.create(device)
-        # TODO: *Tray classes don't allow yet to set the alignment.
-        self.add_item(view)
-        view.show()
-        self._device_icons[device.get_id()] = view
+        try:
+            view = deviceview.create(device)
+            # TODO: *Tray classes don't allow yet to set the alignment.
+            self.add_item(view)
+            view.show()
+            self._device_icons[device.get_id()] = view
+        except Exception, message:
+            import logging
+            logger = logging.getLogger('DevicesTray')
+            logger.warn("Not able to add icon for device [%s], because of "
+                        "an error (%s). Continuing." % (device, message))
 
     def _remove_device(self, device):
         self.remove_item(self._device_icons[device.get_id()])
-- 
1.5.5.1




More information about the Sugar-devel mailing list