From 471a3b15ef0649f170cfb12bf6c23dbee8e4181c Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Mon, 21 Oct 2024 21:26:41 +0800 Subject: [PATCH] fix: incorrect config location This caused by the setting singleton instance (actually, QStandardPath::writableLocation) was used before QApplication was constructed, resulting it doesn't know the application name. So we manually append the name to the path... --- app/settings.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/settings.cpp b/app/settings.cpp index 502800b..56e86fd 100644 --- a/app/settings.cpp +++ b/app/settings.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -149,8 +150,11 @@ Settings::Settings() #endif // defined(FLAG_PORTABLE_MODE_SUPPORT) && defined(Q_OS_WIN) if (configPath.isEmpty()) { - // %LOCALAPPDATA%\ under Windows, ~/.config/ under Linux. - configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); + // Should be %LOCALAPPDATA%\ under Windows, ~/.config/ under Linux. + // Sadly is unknown when Settings object is created (it's before the creation + // of QApplication), so we'll need to append the app name manually. + configPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) % + QDir::separator() % QLatin1String("Pineapple Pictures"); } m_qsettings = new QSettings(QDir(configPath).absoluteFilePath("config.ini"), QSettings::IniFormat, this);