From 55311e41a30575033a9cbe15bc717d9a5eaca56a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 May 2015 08:41:18 +0530 Subject: [PATCH] Open With: Fix unhandled exception when choosing a non-executable file as an open with program --- src/calibre/gui2/open_with.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/open_with.py b/src/calibre/gui2/open_with.py index 4b290df57c..1b7b28dc5f 100644 --- a/src/calibre/gui2/open_with.py +++ b/src/calibre/gui2/open_with.py @@ -104,8 +104,9 @@ if iswindows: if ans: ans = os.path.abspath(ans[0]) if not os.access(ans, os.X_OK): - return error_dialog(parent, _('Cannot execute'), _( + error_dialog(parent, _('Cannot execute'), _( 'The program %s is not an executable file') % ans, show=True) + return qans = ans.replace('"', r'\"') name = friendly_app_name(exe=ans) or os.path.splitext(os.path.basename(ans))[0] return {'cmdline':'"%s" "%%1"' % qans, 'name':name, 'icon_resource':ans + ',0'} @@ -168,8 +169,9 @@ elif isosx: '%s is not a valid OS X application bundle.') % ans, show=True) return app if not os.access(ans, os.X_OK): - return error_dialog(parent, _('Cannot execute'), _( + error_dialog(parent, _('Cannot execute'), _( 'The program %s is not an executable file') % ans, show=True) + return return {'path':ans, 'name': os.path.basename(ans)} @@ -194,8 +196,9 @@ else: if ans: ans = ans[0] if not os.access(ans, os.X_OK): - return error_dialog(parent, _('Cannot execute'), _( + error_dialog(parent, _('Cannot execute'), _( 'The program %s is not an executable file') % ans, show=True) + return return {'Exec':[ans, '%f'], 'Name':os.path.basename(ans)} def finalize_entry(entry):