From 480f1e5b486a1f84a406795c05e9848fc2cda893 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 28 Jul 2021 16:08:20 +0530 Subject: [PATCH] Fix restarting not working on windows when using calibre-debug.exe -g --- src/calibre/gui2/main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 0fdb3689b4..fb8da089d8 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -486,7 +486,9 @@ def communicate(opts, args): def restart_after_quit(): - if iswindows: + e = sys.executable if getattr(sys, 'frozen', False) else sys.argv[0] + is_calibre_debug_exe = os.path.splitext(e)[0].endswith('-debug') + if iswindows and not is_calibre_debug_exe: # detach the stdout/stderr/stdin handles winutil.prepare_for_restart() if after_quit_actions['debug_on_restart']: @@ -506,9 +508,8 @@ def restart_after_quit(): else: cmd.append('calibre') else: - e = sys.executable if getattr(sys, 'frozen', False) else sys.argv[0] cmd = [e] - if os.path.splitext(e)[0].endswith('-debug'): + if is_calibre_debug_exe: cmd.append('-g') prints('Restarting with:', ' '.join(cmd)) subprocess.Popen(cmd)