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>
This commit is contained in:
Dmitry Shachnev 2016-09-10 14:14:32 +03:00
parent 8a2557fbb7
commit 76746ddab6

View File

@ -1068,15 +1068,17 @@ QStyle *QApplication::style()
if (!QApplicationPrivate::app_style) {
// Compile-time search for default style
//
QString style;
if (!QApplicationPrivate::styleOverride.isEmpty()) {
style = QApplicationPrivate::styleOverride.toLower();
} else {
style = QApplicationPrivate::desktopStyleKey();
}
QStyle *&app_style = QApplicationPrivate::app_style;
app_style = QStyleFactory::create(style);
if (!QApplicationPrivate::styleOverride.isEmpty()) {
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());
if (!app_style) {
const QStringList styles = QStyleFactory::keys();
for (const auto &style : styles) {