diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-02-23 17:01:24 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-02-25 14:16:44 +0000 |
commit | 33403f2c79d678afc5b76add2c517d99b9708c32 (patch) | |
tree | 796fb3e1607a14b9e9e7f00a2e35a326ec083ba6 /tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | |
parent | 7bbde34ee012bbe90c4ce76736c6f71b16e64215 (diff) |
Fix crash when accessing QStyleHints before QGuiApplication is constructed.
Make styleHints a static member variable of QGuiApplicationPrivate and
fix accessor accordingly. Extend tst_QApplication::settableStyleHints()
to run without QApplication instance as well and add a similar test
to QGuiApplication.
Task-number: QTBUG-44499
Change-Id: I42b92ef38f7dd512d08d70accfa7dd4f09a22f01
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp')
-rw-r--r-- | tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 35f441c605..3cf7803cfb 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -37,7 +37,9 @@ #include <QtGui/QWindow> #include <QtGui/QScreen> #include <QtGui/QCursor> +#include <QtGui/QFont> #include <QtGui/QPalette> +#include <QtGui/QStyleHints> #include <qpa/qwindowsysteminterface.h> #include <qgenericplugin.h> @@ -74,6 +76,9 @@ private slots: void genericPluginsAndWindowSystemEvents(); void layoutDirection(); void globalShareContext(); + + void settableStyleHints_data(); + void settableStyleHints(); // Needs to run last as it changes style hints. }; void tst_QGuiApplication::cleanup() @@ -961,4 +966,24 @@ void tst_QGuiApplication::globalShareContext() #endif } +void tst_QGuiApplication::settableStyleHints_data() +{ + QTest::addColumn<bool>("appInstance"); + QTest::newRow("app") << true; + QTest::newRow("no-app") << false; +} + +void tst_QGuiApplication::settableStyleHints() +{ + QFETCH(bool, appInstance); + int argc = 0; + QScopedPointer<QGuiApplication> app; + if (appInstance) + app.reset(new QGuiApplication(argc, 0)); + + const int keyboardInputInterval = 555; + QGuiApplication::styleHints()->setKeyboardInputInterval(keyboardInputInterval); + QCOMPARE(QGuiApplication::styleHints()->keyboardInputInterval(), keyboardInputInterval); +} + QTEST_APPLESS_MAIN(tst_QGuiApplication) |