From 592fbc14909dfb9d9e6110e8ee260d9f28d170ed Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 9 Jan 2016 16:56:39 +0530 Subject: [PATCH] Open With: Use a blank icon instead of erroring out on linux in case of malformed desktop files or icon themes --- src/calibre/gui2/open_with.py | 2 ++ src/calibre/utils/open_with/linux.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/calibre/gui2/open_with.py b/src/calibre/gui2/open_with.py index 8be6ce407d..33d0c162b4 100644 --- a/src/calibre/gui2/open_with.py +++ b/src/calibre/gui2/open_with.py @@ -184,6 +184,8 @@ else: def entry_to_item(entry, parent): icon_path = entry.get('Icon') or I('blank.png') + if not isinstance(icon_path, basestring): + icon_path = I('blank.png') ans = QListWidgetItem(QIcon(icon_path), entry.get('Name') or _('Unknown'), parent) ans.setData(ENTRY_ROLE, entry) comment = (entry.get('Comment') or '') diff --git a/src/calibre/utils/open_with/linux.py b/src/calibre/utils/open_with/linux.py index c5f6495235..5fbd70503d 100644 --- a/src/calibre/utils/open_with/linux.py +++ b/src/calibre/utils/open_with/linux.py @@ -191,6 +191,8 @@ def find_programs(extensions): data['Icon'] = icon else: data.pop('Icon') + if not isinstance(data.get('Icon'), basestring): + data.pop('Icon', None) for k in ('Name', 'GenericName', 'Comment'): val = data.get(k) if val: