Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-123791

Crash in qwindows11style with null widget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.7.1, 6.8.0 FF
    • 6.7.0 RC2
    • Widgets: Styles
    • None
    • Windows
    • 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)

      {                 rect.setHeight(1);                 rect.moveTop(center.y());             }

      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.

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            michael.partridge Michael Partridge
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes