Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.7.2, 5.2.0
-
None
-
Win32/Win64 and Linux
-
qtbase/stable: 4d6cb199b828256cb78ff986f2c1a508b339d2ee
Description
According to our design, on new windows activation the tool bar of the previous window is deleted.
Here is a code snipped of QToolButtonPrivate::popupTimerDone() code which crashes in this case:
Q_Q(QToolButton); ... QPointer<QToolButton> that = q; actualMenu->setNoReplayFor(q); if (!mustDeleteActualMenu) //only if action are not in this widget QObject::connect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); QObject::connect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); actualMenu->d_func()->causedPopup.widget = q; actualMenu->d_func()->causedPopup.action = defaultAction; actionsCopy = q->actions(); //(the list of action may be modified in slots) actualMenu->exec(p); QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); if (mustDeleteActualMenu) delete actualMenu; else QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); if (!that) return; ... }
When deleting the toolbar with an open drop down pop-up menu for some tool button the latter is deleted as well.
These deletion is performed within the exec() in line 9.
The pointer to tool button (q) is broken on line 10 but is being used without check.
So I guess, the similar to the line 16, checking of the pointer q is also needed before lines 10 and 14
void QToolButtonPrivate::popupTimerDone() { ... actualMenu->exec(p); if (!that.isNull()) QObject::disconnect(actualMenu, SIGNAL(aboutToHide()), q, SLOT(_q_updateButtonDown())); if (mustDeleteActualMenu) delete actualMenu; else if (!that.isNull()) QObject::disconnect(actualMenu, SIGNAL(triggered(QAction*)), q, SLOT(_q_menuTriggered(QAction*))); ... }
Regards,
David
R&D Engineer, Synopsys Inc.