diff options
authorDavid Faure <>2014-09-23 23:33:40 +0200
committerDavid Faure <>2014-10-12 10:37:45 +0200
commit955c9562bdb07927069f281a8635ce20405051c3 (patch)
parent38c39341b3394f5c9223a96bd65b52984308740c (diff)
QSettings: undo unintentional change of config dir on non-XDG platforms.
c99dfd8f631289 only meant to be able to switch to the test mode of QStandardPaths, not to move the default dir on OS X, iOS, BB10 and Android. So this commit restores it to the previous behavior, to avoid migration issues. The use of XDG_CONFIG_HOME, defaulting to ~/.config, on OS X, is even documented in the current QSettings documentation, even though these paths are non-standard on OS X (granted, the use of ini-style config files isn't either). Task-number: QTBUG-41461 Change-Id: I5eb610ff7ccbdaf6f955ef7f8f7c2658cbecbb86 Reviewed-by: Eike Ziller <> Reviewed-by: Oswald Buddenhagen <> Reviewed-by: Thiago Macieira <>
1 files changed, 10 insertions, 1 deletions
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index f6cd5aa7c9..fd35ae33dc 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -100,6 +100,10 @@ using namespace ABI::Windows::Storage;
#define CSIDL_APPDATA 0x001a // <username>\Application Data
+#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_ANDROID)
// ************************************************************************
// QConfFile
@@ -1041,7 +1045,9 @@ static void initDefaultPaths(QMutexLocker *locker)
windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator());
+#if defined(QT_NO_STANDARDPATHS) || !defined(Q_XDG_PLATFORM)
+ // Non XDG platforms (OS X, iOS, Blackberry, Android...) have used this code path erroneously
+ // for some time now. Moving away from that would require migrating existing settings.
QString userPath;
char *env = getenv("XDG_CONFIG_HOME");
if (env == 0) {
@@ -1056,6 +1062,9 @@ static void initDefaultPaths(QMutexLocker *locker)
userPath += QFile::decodeName(env);
+ // When using a proper XDG platform, use QStandardPaths rather than the above hand-written code;
+ // it makes the use of test mode from unit tests possible.
+ // Ideally all platforms should use this, but see above for the migration issue.
QString userPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation);
userPath += QLatin1Char('/');