From e72ebf7513c89c3ba91f606ab11537ce5a556fde Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Sun, 16 Oct 2011 14:40:42 +0000 Subject: 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 Acked-by: Simon Schampijer --- 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) -- cgit v0.9.1