remove redundant check in QApplication::style()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-31 11:24:56 +03:00
parent 9e89650bef
commit ad9087f180

View file

@ -832,26 +832,24 @@ QStyle *QApplication::style()
return 0;
}
if (!QApplicationPrivate::app_style) {
QString style;
if (!QApplicationPrivate::styleOverride.isEmpty()) {
style = QApplicationPrivate::styleOverride;
} else {
style = QApplicationPrivate::desktopStyleKey();
}
QString style;
if (!QApplicationPrivate::styleOverride.isEmpty()) {
style = QApplicationPrivate::styleOverride;
} else {
style = QApplicationPrivate::desktopStyleKey();
}
QApplicationPrivate::app_style = QStyleFactory::create(style);
if (!QApplicationPrivate::app_style) {
foreach (const QString &style, QStyleFactory::keys()) {
if ((QApplicationPrivate::app_style = QStyleFactory::create(style)))
break;
}
}
if (!QApplicationPrivate::app_style) {
Q_ASSERT(!"No styles available!");
return 0;
QApplicationPrivate::app_style = QStyleFactory::create(style);
if (!QApplicationPrivate::app_style) {
foreach (const QString &style, QStyleFactory::keys()) {
if ((QApplicationPrivate::app_style = QStyleFactory::create(style)))
break;
}
}
if (!QApplicationPrivate::app_style) {
Q_ASSERT(!"No styles available!");
return nullptr;
}
// take ownership of the style
QApplicationPrivate::app_style->setParent(qApp);
@ -984,9 +982,9 @@ void QApplication::setStyle(QStyle *style)
QStyle* QApplication::setStyle(const QString& style)
{
QStyle *s = QStyleFactory::create(style);
if (!s)
return 0;
if (!s) {
return nullptr;
}
setStyle(s);
return s;
}