Skip to content

Commit

Permalink
QApplication: use desktopStyleKey if styleOverride was invalid
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mitya57 committed Sep 28, 2016
1 parent 8a2557f commit 76746dd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/widgets/kernel/qapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 76746dd

Please sign in to comment.