From 496befb51f8f876ab62f78b524e612d940b02956 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Fri, 1 May 2026 01:05:01 -0500 Subject: Port upstream PR #2379: reset CWD to app dir on startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When MO2 is launched by the nxm handler from a browser, CWD is whatever the browser inherited (often /, $HOME, or the user's Desktop). Reset it to the application directory so any code path relying on CWD behaves the same as a normal launch. Cherry-picked from upstream f80ad04. Comment expanded for the Linux context (Qt resource lookup, relative QFile paths, QtWebEngine sandbox helper) — upstream's note only covered QtWebEngineProcess on Windows. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/src/moapplication.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/src/moapplication.cpp b/src/src/moapplication.cpp index 40ec09a..0c50509 100644 --- a/src/src/moapplication.cpp +++ b/src/src/moapplication.cpp @@ -218,6 +218,13 @@ MOApplication::MOApplication(int& argc, char** argv) : QApplication(argc, argv) #ifdef MO2_WEBENGINE configureQtWebEngineProcessPath(); #endif + + // When MO2 is launched by the nxm handler from a browser, CWD is whatever + // the browser inherited (often /, $HOME, or the user's Desktop). Reset it + // to the application directory so that any code path relying on CWD + // (Qt resource lookup, relative QFile paths, QtWebEngine sandbox helper) + // behaves the same as a normal launch. Upstream PR #2379. + QDir::setCurrent(QCoreApplication::applicationDirPath()); } OrganizerCore& MOApplication::core() -- cgit v1.3.1