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

Severe Bug in QDialogButtonBox when adding a QToolButton

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • 6.7.0 RC
    • 6.7.0 FF
    • None
    • Any application that uses widgets
    • All, macOS

    Description

      When adding a second QToolButton to a QDialogButtonBox (which is perfectly legal as a QToolButton is a QAbstractButton) with QDialogButtonBox::addButton(), Qt immediately crashes.
      The reason is the following code in QDialogButtonBoxPrivate::layoutButtons(): The code casts prev to a QPushButton. But a QToolButton is NOT a QPushButton, it is a QAbstractButton. Thus the cast makes pushButton=0x0 and thus calling isDefault() immediately crashes the application.

          q->setFocusProxy(nullptr);
          if (!layoutWidgets.isEmpty()) {
              QWidget *prev = layoutWidgets.constLast();
              for (QWidget *here : layoutWidgets) {
                  QWidget::setTabOrder(prev, here);
                  prev = here;
                  if (auto *pushButton = qobject_cast<QPushButton *>(prev); pushButton->isDefault())
                      q->setFocusProxy(pushButton);
              }
          }
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            frodo Jens
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes