From a6067ed8a48e6b8d4e7935f2c41f04fba452a560 Mon Sep 17 00:00:00 2001 From: nelsoduarte Date: Fri, 8 May 2026 16:41:15 +0100 Subject: [PATCH] fix(i18n): clear _PYI_APPLICATION_HOME_DIR (correct env var for PyI 6.x) Follow-up to #49. PyInstaller 6.x renamed the temp-extraction handoff env var from _MEIPASS2 to _PYI_APPLICATION_HOME_DIR. Verified by extracting strings from the runw.exe bootloader shipped with PyInstaller 6.19. Clearing only _MEIPASS2 had no effect on modern builds, so the language-change relaunch crash could still surface. Clear both names (legacy + current) so the fix works regardless of the PyInstaller version we ship with. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/window.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/window.py b/app/window.py index f5c979c..c676079 100644 --- a/app/window.py +++ b/app/window.py @@ -948,14 +948,16 @@ def _restart_app(self): program = sys.executable args = [script] + pdf_args cwd = os.path.dirname(script) or os.getcwd() - # PyInstaller --onefile sets _MEIPASS2 to its temp extraction - # folder. The parent deletes that folder on exit, so the child - # must perform its own extraction instead of reusing ours. + # PyInstaller --onefile points _PYI_APPLICATION_HOME_DIR (or the + # legacy _MEIPASS2) at our temp extraction folder. The parent + # deletes that folder on exit, so the child must perform its + # own extraction instead of reusing ours. proc = QProcess() proc.setProgram(program) proc.setArguments(args) proc.setWorkingDirectory(cwd) env = QProcessEnvironment.systemEnvironment() + env.remove("_PYI_APPLICATION_HOME_DIR") env.remove("_MEIPASS2") proc.setProcessEnvironment(env) proc.startDetached()