From 3eb5f0433f79f0c0fda49e00898cd93d3bd73b67 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sun, 23 Feb 2014 12:50:42 +0100 Subject: 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 --- src/core/ksharedconfig.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') 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::ConstIterator it = list->constBegin(); it != list->constEnd(); ++it) { if ((*it)->name() == fileName && -- cgit v1.2.1