summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qapplication.cpp
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2016-09-10 14:14:32 +0300
committerDmitry Shachnev <mitya57@gmail.com>2016-09-28 15:33:17 +0000
commit76746ddab6fc44601d036e0bd3c0000aa6f18f0e (patch)
treec3cba7f33b6284363b8b21ec9b6f21dce03e1e41 /src/widgets/kernel/qapplication.cpp
parent8a2557fbb7a0202a3de3846d10ed57d2d93e6de2 (diff)
QApplication: use desktopStyleKey if styleOverride was invalid
When the application is passed an invalid style option, we should fall back to the style provided by the platform theme, not to the first available style. Change-Id: I59e25b00d4a32221dea7c960d0f4e0068247b2dd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/widgets/kernel/qapplication.cpp')
-rw-r--r--src/widgets/kernel/qapplication.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 9b8677e6a8..7fa3b26e45 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -1068,15 +1068,17 @@ QStyle *QApplication::style()
if (!QApplicationPrivate::app_style) {
// Compile-time search for default style
//
- QString style;
+ QStyle *&app_style = QApplicationPrivate::app_style;
+
if (!QApplicationPrivate::styleOverride.isEmpty()) {
- style = QApplicationPrivate::styleOverride.toLower();
- } else {
- style = QApplicationPrivate::desktopStyleKey();
+ const QString style = QApplicationPrivate::styleOverride.toLower();
+ app_style = QStyleFactory::create(style);
+ if (!app_style)
+ qWarning("QApplication: invalid style override passed, ignoring it.");
}
+ if (!app_style)
+ app_style = QStyleFactory::create(QApplicationPrivate::desktopStyleKey());
- QStyle *&app_style = QApplicationPrivate::app_style;
- app_style = QStyleFactory::create(style);
if (!app_style) {
const QStringList styles = QStyleFactory::keys();
for (const auto &style : styles) {