aboutsummaryrefslogtreecommitdiff
path: root/autotests/ksharedconfig_in_global_object.cpp
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2015-04-04 13:40:21 +0200
committerDavid Faure <faure@kde.org>2015-04-04 13:44:01 +0200
commitee599bfa17f7e56b0db1a4afbbfe929ec90f2c9d (patch)
treeeef98e45e0714e13dde055e9a684290588d97dc8 /autotests/ksharedconfig_in_global_object.cpp
parent731a9b83f4bd1f2dc840cfae84edcd0b533810aa (diff)
downloadkconfig-ee599bfa17f7e56b0db1a4afbbfe929ec90f2c9d.tar.gz
kconfig-ee599bfa17f7e56b0db1a4afbbfe929ec90f2c9d.tar.bz2
KConfig: fix using KSharedConfig in global object destructor.
ksharedconfig_in_global_object.cpp is now in kdelibs4 too (where it works) and reproduces Albert's KgDifficulty testcase. CHANGELOG: fix assert when using KSharedConfig in a global object destructor. REVIEW: 122232
Diffstat (limited to 'autotests/ksharedconfig_in_global_object.cpp')
-rw-r--r--autotests/ksharedconfig_in_global_object.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/autotests/ksharedconfig_in_global_object.cpp b/autotests/ksharedconfig_in_global_object.cpp
new file mode 100644
index 00000000..7a4f66bf
--- /dev/null
+++ b/autotests/ksharedconfig_in_global_object.cpp
@@ -0,0 +1,62 @@
+/* This file is part of the KDE project
+ Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License version 2 as published by the Free Software Foundation.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+
+*/
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QtGlobal>
+#include <QTimer>
+#include <ksharedconfig.h>
+#include <kconfiggroup.h>
+#include <stdio.h>
+
+class Tester
+{
+public:
+ void initConfig();
+ ~Tester();
+};
+
+void Tester::initConfig()
+{
+ fprintf(stderr, "app Tester\n");
+ KConfigGroup group(KSharedConfig::openConfig(), "test");
+ group.writeEntry("test", 0);
+}
+
+Tester::~Tester()
+{
+ fprintf(stderr, "app ~Tester\n");
+ KConfigGroup group(KSharedConfig::openConfig(), "test");
+ group.writeEntry("test", 1);
+}
+
+Q_GLOBAL_STATIC(Tester, globalTestObject)
+
+int main(int argc, char **argv)
+{
+ qputenv("QT_FATAL_WARNINGS", "1");
+ QCoreApplication app(argc, argv);
+
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
+
+ Tester *t = globalTestObject();
+ t->initConfig();
+
+ QTimer::singleShot(0, qApp, SLOT(quit()));
+ return app.exec();
+}