diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-07-19 19:51:41 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2016-07-19 20:14:40 +0200 |
commit | 782ebeada125e3d8a293c7806e34cc737c30ddda (patch) | |
tree | 5516ad24a7532d650289758abd5e92a35bc2240e /src/corelib/io/qsettings.cpp | |
parent | 091df96fb8da356dc9de81dc390f55e66d4d7c01 (diff) | |
parent | 62cbb434579a56871f0917bc306d592055381c00 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
qmake/library/qmakebuiltins.cpp
qmake/library/qmakeevaluator.cpp
qmake/library/qmakeevaluator.h
qmake/project.h
QMakeEvaluator:
* evaluateConditional(): one side changed return type, the other
changed a parameter type.
* split_value_list(): one side changed a parameter adjacent to where ...
* expandVariableReferences(): ... the other killed one overload and
changed the survivor
src/corelib/io/qlockfile_unix.cpp
One side changed a #if condition, the other moved NETBSD's part of
what it controlled.
src/corelib/tools/qdatetime.cpp
One side fixed a reachable Q_UNREACHABLE in toMSecsSinceEpoch(), the
other moved it from the private class to the public one, in the midst
of the "short date-time" optimization, which confused diff entirely.
One side changed a QStringLiteral to QLatin1String, the other rewrote
adjoining code.
src/network/kernel/qauthenticator.cpp
Both rewrote a line, equivalently; kept the dev version.
src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
One side changed #if-ery that the other removed.
tools/configure/configureapp.cpp
One side added a check to -target parsing; the other killed -target.
tests/auto/testlib/selftests/expected_cmptest.lightxml
tests/auto/testlib/selftests/expected_cmptest.teamcity
tests/auto/testlib/selftests/expected_cmptest.txt
tests/auto/testlib/selftests/expected_cmptest.xml
tests/auto/testlib/selftests/expected_cmptest.xunitxml
Regenerated using generate_expected_output.py
I note that quite a few other expected_* come out changed, now.
There was no git-conflict in
src/widgets/kernel/qformlayout.cpp
but it didn't compile; one side removed some unused methods; the other
found uses for one of them. Put FixedColumnMatrix<>::removeRow(int)
back for its new user.
Change-Id: I8cc2a71add48c0a848e13cfc47b5a7754e8ca584
Diffstat (limited to 'src/corelib/io/qsettings.cpp')
-rw-r--r-- | src/corelib/io/qsettings.cpp | 109 |
1 files changed, 43 insertions, 66 deletions
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index ed3273eb2e..856108e417 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -248,8 +248,7 @@ QString QSettingsPrivate::actualKey(const QString &key) const { QString n = normalizedKey(key); Q_ASSERT_X(!n.isEmpty(), "QSettings", "empty key"); - n.prepend(groupPrefix); - return n; + return groupPrefix + n; } /* @@ -324,10 +323,9 @@ void QSettingsPrivate::processChild(QStringRef key, ChildSpec spec, QStringList void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group) { groupStack.push(group); - if (!group.name().isEmpty()) { - groupPrefix += group.name(); - groupPrefix += QLatin1Char('/'); - } + const QString name = group.name(); + if (!name.isEmpty()) + groupPrefix += name + QLatin1Char('/'); } /* @@ -403,9 +401,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v) case QVariant::ByteArray: { QByteArray a = v.toByteArray(); - result = QLatin1String("@ByteArray("); - result += QString::fromLatin1(a.constData(), a.size()); - result += QLatin1Char(')'); + result = QLatin1String("@ByteArray(") + + QLatin1String(a.constData(), a.size()) + + QLatin1Char(')'); break; } @@ -425,33 +423,17 @@ QString QSettingsPrivate::variantToString(const QVariant &v) #ifndef QT_NO_GEOM_VARIANT case QVariant::Rect: { QRect r = qvariant_cast<QRect>(v); - result += QLatin1String("@Rect("); - result += QString::number(r.x()); - result += QLatin1Char(' '); - result += QString::number(r.y()); - result += QLatin1Char(' '); - result += QString::number(r.width()); - result += QLatin1Char(' '); - result += QString::number(r.height()); - result += QLatin1Char(')'); + result = QString::asprintf("@Rect(%d %d %d %d)", r.x(), r.y(), r.width(), r.height()); break; } case QVariant::Size: { QSize s = qvariant_cast<QSize>(v); - result += QLatin1String("@Size("); - result += QString::number(s.width()); - result += QLatin1Char(' '); - result += QString::number(s.height()); - result += QLatin1Char(')'); + result = QString::asprintf("@Size(%d %d)", s.width(), s.height()); break; } case QVariant::Point: { QPoint p = qvariant_cast<QPoint>(v); - result += QLatin1String("@Point("); - result += QString::number(p.x()); - result += QLatin1Char(' '); - result += QString::number(p.y()); - result += QLatin1Char(')'); + result = QString::asprintf("@Point(%d %d)", p.x(), p.y()); break; } #endif // !QT_NO_GEOM_VARIANT @@ -474,9 +456,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v) s << v; } - result = QLatin1String(typeSpec); - result += QString::fromLatin1(a.constData(), a.size()); - result += QLatin1Char(')'); + result = QLatin1String(typeSpec) + + QLatin1String(a.constData(), a.size()) + + QLatin1Char(')'); #else Q_ASSERT(!"QSettings: Cannot save custom types without QDataStream support"); #endif @@ -647,8 +629,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, && ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'))) { - result += "\\x"; - result += QByteArray::number(ch, 16); + result += "\\x" + QByteArray::number(ch, 16); continue; } @@ -687,8 +668,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, break; default: if (ch <= 0x1F || (ch >= 0x7F && !useCodec)) { - result += "\\x"; - result += QByteArray::number(ch, 16); + result += "\\x" + QByteArray::number(ch, 16); escapeNextIfDigit = true; #ifndef QT_NO_TEXTCODEC } else if (useCodec) { @@ -1038,10 +1018,33 @@ static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope) return int((uint(format) << 1) | uint(scope == QSettings::SystemScope)); } +#ifndef Q_OS_WIN +static QString make_user_path() +{ + static Q_CONSTEXPR QChar sep = QLatin1Char('/'); +#ifndef QSETTINGS_USE_QSTANDARDPATHS + // Non XDG platforms (OS X, iOS, Android...) have used this code path erroneously + // for some time now. Moving away from that would require migrating existing settings. + QByteArray env = qgetenv("XDG_CONFIG_HOME"); + if (env.isEmpty()) { + return QDir::homePath() + QLatin1String("/.config/"); + } else if (env.startsWith('/')) { + return QFile::decodeName(env) + sep; + } else { + return QDir::homePath() + sep + QFile::decodeName(env) + sep; + } +#else + // 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. + return QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + sep; +#endif +} +#endif // !Q_OS_WIN + static void initDefaultPaths(QMutexLocker *locker) { PathHash *pathHash = pathHashFunc(); - QString systemPath; locker->unlock(); @@ -1050,8 +1053,7 @@ static void initDefaultPaths(QMutexLocker *locker) avoid a dead-lock, we can't hold the global mutex while calling it. */ - systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath); - systemPath += QLatin1Char('/'); + QString systemPath = QLibraryInfo::location(QLibraryInfo::SettingsPath) + QLatin1Char('/'); locker->relock(); if (pathHash->isEmpty()) { @@ -1067,38 +1069,14 @@ static void initDefaultPaths(QMutexLocker *locker) pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), windowsConfigPath(CSIDL_COMMON_APPDATA) + QDir::separator()); #else - -#ifndef QSETTINGS_USE_QSTANDARDPATHS - // Non XDG platforms (OS X, iOS, Android...) have used this code path erroneously - // for some time now. Moving away from that would require migrating existing settings. - QString userPath; - QByteArray env = qgetenv("XDG_CONFIG_HOME"); - if (env.isEmpty()) { - userPath = QDir::homePath(); - userPath += QLatin1Char('/'); - userPath += QLatin1String(".config"); - } else if (env.startsWith('/')) { - userPath = QFile::decodeName(env); - } else { - userPath = QDir::homePath(); - userPath += QLatin1Char('/'); - userPath += QFile::decodeName(env); - } -#else - // 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); -#endif - userPath += QLatin1Char('/'); - + const QString userPath = make_user_path(); pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::UserScope), userPath); pathHash->insert(pathHashKey(QSettings::IniFormat, QSettings::SystemScope), systemPath); #ifndef Q_OS_MAC pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::UserScope), userPath); pathHash->insert(pathHashKey(QSettings::NativeFormat, QSettings::SystemScope), systemPath); #endif -#endif +#endif // Q_OS_WIN } } @@ -3486,8 +3464,7 @@ QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc r return QSettings::InvalidFormat; QConfFileCustomFormat info; - info.extension = QLatin1Char('.'); - info.extension += extension; + info.extension = QLatin1Char('.') + extension; info.readFunc = readFunc; info.writeFunc = writeFunc; info.caseSensitivity = caseSensitivity; |