From 8387d87bdcf7dfb359515f44b17f523791bc8edb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 2 Mar 2017 08:55:35 +0100 Subject: QDialogButtonGroup: Fix removal of deleted buttons As the destroyed() signal is emitted from ~QObject, it is not allowed to use static_cast to a QAbstractButton on that pointer anymore. And the qobject_cast will also fail which will keep a dangling pointer in the hash. Change-Id: If0d22fcc30cde87e771e70914c3afb04ea207289 Reviewed-by: Marc Mutz --- src/widgets/widgets/qdialogbuttonbox.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/widgets/widgets/qdialogbuttonbox.cpp') diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp index 23158cf82f..984669f29a 100644 --- a/src/widgets/widgets/qdialogbuttonbox.cpp +++ b/src/widgets/widgets/qdialogbuttonbox.cpp @@ -716,8 +716,7 @@ void QDialogButtonBox::removeButton(QAbstractButton *button) return; // Remove it from the standard button hash first and then from the roles - if (QPushButton *pushButton = qobject_cast(button)) - d->standardButtonHash.remove(pushButton); + d->standardButtonHash.remove(reinterpret_cast(button)); for (int i = 0; i < NRoles; ++i) { QList &list = d->buttonLists[i]; for (int j = 0; j < list.count(); ++j) { @@ -883,7 +882,7 @@ void QDialogButtonBoxPrivate::_q_handleButtonDestroyed() Q_Q(QDialogButtonBox); if (QObject *object = q->sender()) { QBoolBlocker skippy(internalRemove); - q->removeButton(static_cast(object)); + q->removeButton(reinterpret_cast(object)); } } -- cgit v1.2.3