aboutsummaryrefslogtreecommitdiff
path: root/src/core/ksharedconfig.cpp
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2014-02-23 12:50:42 +0100
committerDavid Faure <faure@kde.org>2014-02-27 21:13:18 +0100
commit3eb5f0433f79f0c0fda49e00898cd93d3bd73b67 (patch)
treeb8fc72b2cc4ce68894f72724459bbf9d30f0ca97 /src/core/ksharedconfig.cpp
parenteb604bc60bcc5cd94328de725ac357e728eae624 (diff)
downloadkconfig-3eb5f0433f79f0c0fda49e00898cd93d3bd73b67.tar.gz
kconfig-3eb5f0433f79f0c0fda49e00898cd93d3bd73b67.tar.bz2
Fix interference from kdeplatformtheme into unittests
kdeplatformtheme would load kdeglobals and the app config file, in order to load settings, before the unittests get a chance to call QStandardPaths::setTestModeEnabled(true). As a result, the test would keep getting references to "wrong" shared config objects, pointing to the real user's locations rather than the test directories. This fixes e.g. kconfigdialog_unittest from kconfigwidgets for me (it only passes on build.kde.org because it doesn't install frameworkintegration for testing this framework) REVIEW: 115963
Diffstat (limited to 'src/core/ksharedconfig.cpp')
-rw-r--r--src/core/ksharedconfig.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/core/ksharedconfig.cpp b/src/core/ksharedconfig.cpp
index 4f0e8d69..34947065 100644
--- a/src/core/ksharedconfig.cpp
+++ b/src/core/ksharedconfig.cpp
@@ -64,6 +64,13 @@ KSharedConfigPtr KSharedConfig::openConfig(const QString &_fileName,
fileName = KConfig::mainConfigName();
}
+ static bool wasTestModeEnabled = false;
+ if (!wasTestModeEnabled && QStandardPaths::isTestModeEnabled()) {
+ wasTestModeEnabled = true;
+ list->clear();
+ list->mainConfig = Q_NULLPTR;
+ }
+
if (list) {
for (QList<KSharedConfig *>::ConstIterator it = list->constBegin(); it != list->constEnd(); ++it) {
if ((*it)->name() == fileName &&