diff options
author | Sascha Silbe <silbe@activitycentral.com> | 2011-10-16 14:40:42 (GMT) |
---|---|---|
committer | Sascha Silbe <silbe@activitycentral.com> | 2011-10-18 15:42:51 (GMT) |
commit | e72ebf7513c89c3ba91f606ab11537ce5a556fde (patch) | |
tree | a567c151e31a62b9ac4bce4f815e27794d8a82e9 | |
parent | 64aae3b42c259af85db4051aa54c74a1b303f21b (diff) |
Journal: don't fail to load if an activity icon is broken (fixes SL#3200)
If the activity-provided icon could not be loaded, the Journal previously
died on start-up, rendering Sugar effectively unusable. Now we fall back to
the standard icon (in the "What" filter combo box).
SL#3203 has been filed to remind us to audit the code for similar breakages.
Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r-- | src/jarabe/journal/journaltoolbox.py | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/jarabe/journal/journaltoolbox.py b/src/jarabe/journal/journaltoolbox.py index cdf6a77..2aa4153 100644 --- a/src/jarabe/journal/journaltoolbox.py +++ b/src/jarabe/journal/journaltoolbox.py @@ -24,6 +24,7 @@ import time import gobject import gio +import glib import gtk from sugar.graphics.palette import Palette @@ -319,19 +320,33 @@ class SearchToolbar(gtk.Toolbar): for service_name in model.get_unique_values('activity'): activity_info = registry.get_bundle(service_name) - if not activity_info is None: - if os.path.exists(activity_info.get_icon()): + if activity_info is None: + continue + + if service_name == current_value: + combo_model = self._what_search_combo.get_model() + current_value_index = len(combo_model) + + # try activity-provided icon + if os.path.exists(activity_info.get_icon()): + try: self._what_search_combo.append_item(service_name, activity_info.get_name(), file_name=activity_info.get_icon()) + except glib.GError, exception: + logging.warning('Falling back to default icon for' + ' "what" filter because %r (%r) has an' + ' invalid icon: %s', + activity_info.get_name(), + str(service_name), exception) else: - self._what_search_combo.append_item(service_name, - activity_info.get_name(), - icon_name='application-octet-stream') + continue + + # fall back to generic icon + self._what_search_combo.append_item(service_name, + activity_info.get_name(), + icon_name='application-octet-stream') - if service_name == current_value: - current_value_index = \ - len(self._what_search_combo.get_model()) - 1 finally: self._what_search_combo.handler_unblock( self._what_combo_changed_sid) |