From ec3e4d101d48182010b82ab26970c3f7ccff464f Mon Sep 17 00:00:00 2001 From: Andrew Rabert Date: Fri, 26 Dec 2025 15:43:06 -0500 Subject: [PATCH] Fix portable mode --- src/main.cpp | 8 +++++--- src/shared/Paths.cpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1614a6f..abbc909 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -226,6 +226,9 @@ int main(int argc, char *argv[]) // Now parse the command line. parser.process(arguments); + + // Detect portable mode while QCoreApplication exists (needed for applicationDirPath) + Paths::detectAndEnablePortableMode(); } if (parser.isSet("help")) @@ -243,10 +246,9 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } - // Check for portable mode (marker file next to exe) - if (Paths::detectAndEnablePortableMode()) + // Set QSettings path for portable mode + if (Paths::isPortableMode()) { - // Portable mode sets its own paths, skip config-dir QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, Paths::globalDataDir()); } diff --git a/src/shared/Paths.cpp b/src/shared/Paths.cpp index b4f031b..2efe0d9 100644 --- a/src/shared/Paths.cpp +++ b/src/shared/Paths.cpp @@ -7,8 +7,8 @@ #include #include +#include #include -#include #include #include "Names.h" #include "Version.h" @@ -41,7 +41,7 @@ bool Paths::isPortableMode() bool Paths::detectAndEnablePortableMode() { #ifdef Q_OS_WIN - QString appDir = QGuiApplication::applicationDirPath(); + QString appDir = QCoreApplication::applicationDirPath(); // Check for portable marker file if (QFile::exists(appDir + "/portable") || QFile::exists(appDir + "/portable.txt"))