QWindows11Style: Check for nullptr after qobject_cast

Fixes: QTBUG-123791
Pick-to: 6.7
Change-Id: I050196bdf45754509a223c89652e0be7e0160a98
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Wladimir Leuschner 2024-03-27 13:32:43 +01:00
parent 9f464716b0
commit a35f57d429

View File

@ -1199,7 +1199,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
break;
case QStyle::CE_ProgressBarGroove:{
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
const QProgressBar* bar = qobject_cast<const QProgressBar*>(widget);
if (const QProgressBar* bar = qobject_cast<const QProgressBar*>(widget)) {
QRect rect = subElementRect(SE_ProgressBarContents, progbaropt, widget);
QPointF center = rect.center();
if (bar->orientation() & Qt::Horizontal) {
@ -1213,11 +1213,12 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
painter->setBrush(Qt::gray);
painter->drawRect(rect);
}
}
break;
}
case QStyle::CE_ProgressBarContents:
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
const QProgressBar* bar = qobject_cast<const QProgressBar*>(widget);
if (const QProgressBar* bar = qobject_cast<const QProgressBar*>(widget)) {
const qreal progressBarThickness = 3;
const qreal progressBarHalfThickness = progressBarThickness / 2.0;
QRectF rect = subElementRect(SE_ProgressBarContents, progbaropt, widget);
@ -1267,6 +1268,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
painter->setBrush(progbaropt->palette.accent());
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
}
}
break;
case QStyle::CE_ProgressBarLabel:
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
@ -1592,7 +1594,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
}
case QStyle::CE_ItemViewItem: {
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget)) {
QRect checkRect = proxy()->subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget);
QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, vopt, widget);
QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt, widget);
@ -1682,6 +1684,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
}
}
}
}
break;
}
default: