Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.7.0 RC2
-
None
-
-
a35f57d42 (dev), 8b193397f (6.7)
Description
qwindows11style crashes when drawing progress bar if qobject_cast fails.
I haven't debugged yet (end of my work day right now), but wanted to report in case the fix is obvious for you (should it just check the result of the qobject_cast?).
Here's the code:
case QStyle::CE_ProgressBarGroove:{
if (const QStyleOptionProgressBar* progbaropt = qstyleoption_cast<const QStyleOptionProgressBar*>(option)) {
const QProgressBar bar = qobject_cast<const QProgressBar*>(widget);*
QRectF rect = subElementRect(SE_ProgressBarContents, progbaropt, widget);
QPointF center = rect.center();
if (bar->orientation() & Qt::Horizontal)
else
{ rect.setWidth(1); rect.moveLeft(center.x()); }(from qwindows11style.cpp)
If widget isn't a QProgressBar* then the cast fails and a crash results.
Update: initial value of widget is nullptr (from initiating call of QStyle::drawControl using default value for widget parameter), rather than being the wrong type. In any case, adding a null check for "bar" will avoid the crash.