From 054d849879647fd4cf90c4f622877d3a11720bb2 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 28 Jun 2014 00:19:31 +0200 Subject: KSharedConfig: move mainConfig and wasTestEnabled to the thread storage. This enables the mainConfig optimization in all threads, and ensures the user warning only happens in the main thread. The test-mode-enabled logic is only really useful in the main thread, but it's simpler to just do it in all threads. REVIEW: 118985 --- autotests/kconfigtest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'autotests/kconfigtest.cpp') diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index b621ac55..3156aa5e 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -95,6 +95,9 @@ void KConfigTest::initTestCase() // to make sure all files from a previous failed run are deleted cleanupTestCase(); + KSharedConfigPtr mainConfig = KSharedConfig::openConfig(); + mainConfig->group("Main").writeEntry("Key", "Value"); + KConfig sc(TEST_SUBDIR "kconfigtest"); KConfigGroup cg(&sc, "AAA"); @@ -1411,6 +1414,11 @@ void KConfigTest::testSharedConfig() myConfigGroup = KConfigGroup(config, "Hello"); } QCOMPARE(myConfigGroup.readEntry("stringEntry1"), QString(STRINGENTRY1)); + + // Get the main config + KSharedConfigPtr mainConfig = KSharedConfig::openConfig(); + KConfigGroup mainGroup(mainConfig, "Main"); + QCOMPARE(mainGroup.readEntry("Key", QString()), QString("Value")); } void KConfigTest::testLocaleConfig() @@ -1676,6 +1684,8 @@ void KConfigTest::testThreads() futures << QtConcurrent::run(this, &KConfigTest::testAddConfigSources); futures << QtConcurrent::run(this, &KConfigTest::testSimple); futures << QtConcurrent::run(this, &KConfigTest::testDefaults); + futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig); + futures << QtConcurrent::run(this, &KConfigTest::testSharedConfig); // QEXPECT_FAIL triggers race conditions, it should be fixed to use QThreadStorage... //futures << QtConcurrent::run(this, &KConfigTest::testDeleteWhenLocalized); //futures << QtConcurrent::run(this, &KConfigTest::testEntryMap); -- cgit v1.2.1