-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.7.0 FF
-
None
-
Any application that uses widgets
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);
}
}