Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.12.1
Description
In the context of an application which manages several kinds of documents (and therefore several kinds of views), the application's main menu bar is rebuilt according to the document type of the active view.
If triggering an action from a menu entry of document A results in the creation and display of a document B for which such a menu entry doesn't exist, then the corresponding QMenu is deleted and the application crashes in QMenuPrivate::activateAction() because the object is deleted. Crash happens at line 1445 of qmenu.cpp:
actionAboutToTrigger = 0;
because actionAboutToTrigger is an object property.
A simple solution would be to use a guarded pointer before calling:
activateCausedStack(causedStack, action, action_e, self);
which might results in the deletion of the current object. i.e. something like:
QPointer<QMenuPrivate> guardedPtr(this); activateCausedStack(causedStack, action, action_e, self); if (!guardedPtf) return;
The other alternative, which consists in using deleteLater() on the QMenu object instead of directly deleting it when rebuilding the menu bar unfortunately doesn't work if for some reasons QApplication::processEvents() is called after the menu is rebuilt.
Attachments
Issue Links
- is duplicated by
-
QTBUG-106718 [REG] QCoreApplication::processEvents() processes deferred delete
-
- Closed
-