aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2016-04-27 17:12:12 +0200
committerAleix Pol <aleixpol@kde.org>2016-04-27 17:12:12 +0200
commitf31fdc92a51c23292ff81f57be0991cd772f2099 (patch)
treec25140c72d0651513507fb3c6d81d50f519920f6 /src
parent61757c5aa46c7f851dd2d44adf7e69dfd52b40f9 (diff)
downloadkconfig-f31fdc92a51c23292ff81f57be0991cd772f2099.tar.gz
kconfig-f31fdc92a51c23292ff81f57be0991cd772f2099.tar.bz2
Make kdeglobals file path static as intended
Diffstat (limited to 'src')
-rw-r--r--src/core/kconfig.cpp11
-rw-r--r--src/core/kconfig_p.h1
2 files changed, 5 insertions, 7 deletions
diff --git a/src/core/kconfig.cpp b/src/core/kconfig.cpp
index 5b72b1ad..ad52da9b 100644
--- a/src/core/kconfig.cpp
+++ b/src/core/kconfig.cpp
@@ -58,6 +58,7 @@ bool KConfigPrivate::mappingsRegistered = false;
Q_GLOBAL_STATIC(QStringList, s_globalFiles) // For caching purposes.
static QBasicMutex s_globalFilesMutex;
+Q_GLOBAL_STATIC_WITH_ARGS(QString, sGlobalFileName, (QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/kdeglobals")))
#ifndef Q_OS_WIN
static const Qt::CaseSensitivity sPathCaseSensitivity = Qt::CaseSensitive;
@@ -72,8 +73,6 @@ KConfigPrivate::KConfigPrivate(KConfig::OpenFlags flags,
bFileImmutable(false), bForceGlobal(false), bSuppressGlobal(false),
configState(KConfigBase::NoAccess)
{
- sGlobalFileName = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1String("/kdeglobals");
-
static QBasicAtomicInt use_etc_kderc = Q_BASIC_ATOMIC_INITIALIZER(-1);
if (use_etc_kderc.load() < 0) {
use_etc_kderc.store( !qEnvironmentVariableIsSet("KDE_SKIP_KDERC")); // for unit tests
@@ -456,7 +455,7 @@ bool KConfig::sync()
d->bDirty = false; // will revert to true if a config write fails
if (d->wantGlobals() && writeGlobals) {
- QExplicitlySharedDataPointer<KConfigBackend> tmp = KConfigBackend::create(d->sGlobalFileName);
+ QExplicitlySharedDataPointer<KConfigBackend> tmp = KConfigBackend::create(*sGlobalFileName);
if (d->configState == ReadWrite && !tmp->lock()) {
qWarning() << "couldn't lock global file";
@@ -598,7 +597,7 @@ void KConfigPrivate::changeFileName(const QString &name)
} else if (wantGlobals()) { // accessing "kdeglobals" by specifying no filename and NoCascade - XXX used anywhere?
resourceType = QStandardPaths::GenericConfigLocation;
fileName = QStringLiteral("kdeglobals");
- file = sGlobalFileName;
+ file = *sGlobalFileName;
} else {
// anonymous config
openFlags = KConfig::SimpleConfig;
@@ -616,7 +615,7 @@ void KConfigPrivate::changeFileName(const QString &name)
Q_ASSERT(!file.isEmpty());
- bSuppressGlobal = (file.compare(sGlobalFileName, sPathCaseSensitivity) == 0);
+ bSuppressGlobal = (file.compare(*sGlobalFileName, sPathCaseSensitivity) == 0);
if (bDynamicBackend || !mBackend) { // allow dynamic changing of backend
mBackend = KConfigBackend::create(file);
@@ -692,7 +691,7 @@ void KConfigPrivate::parseGlobalFiles()
Q_FOREACH (const QString &file, globalFiles) {
KConfigBackend::ParseOptions parseOpts = KConfigBackend::ParseGlobal | KConfigBackend::ParseExpansions;
- if (file.compare(sGlobalFileName, sPathCaseSensitivity) != 0)
+ if (file.compare(*sGlobalFileName, sPathCaseSensitivity) != 0)
parseOpts |= KConfigBackend::ParseDefaults;
QExplicitlySharedDataPointer<KConfigBackend> backend = KConfigBackend::create(file);
diff --git a/src/core/kconfig_p.h b/src/core/kconfig_p.h
index 4b5b7e3c..beda6e4b 100644
--- a/src/core/kconfig_p.h
+++ b/src/core/kconfig_p.h
@@ -80,7 +80,6 @@ private:
bool bForceGlobal: 1;
bool bSuppressGlobal: 1;
- QString sGlobalFileName;
static bool mappingsRegistered;
KEntryMap entryMap;