From 33403f2c79d678afc5b76add2c517d99b9708c32 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 23 Feb 2015 17:01:24 +0100 Subject: 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 --- src/gui/kernel/qstylehints.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gui/kernel/qstylehints.cpp') diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index a0f98383ff..b7af2e759f 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -35,6 +35,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -46,6 +47,10 @@ static inline QVariant hint(QPlatformIntegration::StyleHint h) static inline QVariant themeableHint(QPlatformTheme::ThemeHint th, QPlatformIntegration::StyleHint ih) { + if (!QCoreApplication::instance()) { + qWarning() << "Must construct a QGuiApplication before accessing a platform theme hint."; + return QVariant(); + } if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { const QVariant themeHint = theme->themeHint(th); if (themeHint.isValid()) -- cgit v1.2.3