QWindows11Style: Check for nullptr after qobject_cast
Fixes: QTBUG-123791 Change-Id: I050196bdf45754509a223c89652e0be7e0160a98 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit a35f57d4290c898cda686fccfa7a7a3e08beffd6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
84d5754a81
commit
8b193397f5
@ -1199,7 +1199,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
break;
|
break;
|
||||||
case QStyle::CE_ProgressBarGroove:{
|
case QStyle::CE_ProgressBarGroove:{
|
||||||
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
|
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);
|
QRect rect = subElementRect(SE_ProgressBarContents, progbaropt, widget);
|
||||||
QPointF center = rect.center();
|
QPointF center = rect.center();
|
||||||
if (bar->orientation() & Qt::Horizontal) {
|
if (bar->orientation() & Qt::Horizontal) {
|
||||||
@ -1213,11 +1213,12 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
painter->setBrush(Qt::gray);
|
painter->setBrush(Qt::gray);
|
||||||
painter->drawRect(rect);
|
painter->drawRect(rect);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QStyle::CE_ProgressBarContents:
|
case QStyle::CE_ProgressBarContents:
|
||||||
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
|
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 progressBarThickness = 3;
|
||||||
const qreal progressBarHalfThickness = progressBarThickness / 2.0;
|
const qreal progressBarHalfThickness = progressBarThickness / 2.0;
|
||||||
QRectF rect = subElementRect(SE_ProgressBarContents, progbaropt, widget);
|
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->setBrush(progbaropt->palette.accent());
|
||||||
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case QStyle::CE_ProgressBarLabel:
|
case QStyle::CE_ProgressBarLabel:
|
||||||
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
|
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: {
|
case QStyle::CE_ItemViewItem: {
|
||||||
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
|
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 checkRect = proxy()->subElementRect(SE_ItemViewItemCheckIndicator, vopt, widget);
|
||||||
QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, vopt, widget);
|
QRect iconRect = proxy()->subElementRect(SE_ItemViewItemDecoration, vopt, widget);
|
||||||
QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt, widget);
|
QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt, widget);
|
||||||
@ -1682,6 +1684,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user