From de9145dcd904068256e28e130fdfda2e8014efe8 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 24 Mar 2015 20:56:48 +0100 Subject: Menu: Separate dismiss and destroy actions This avoids issues when the action is triggered from a Menu and the slot ends up processing pending events, effectively deleting an object while one of its QML signal handlers is being executed. The reason being that we used to call deleteLater() on the menu popup window while still in the mouse event handler. Now, we do the same thing in three separate steps. 1. Close/dismiss the menu popups, 2. trigger the action, and 3. delete the popups. This keeps the menu popups and their contents alive until we return from the action triggered handler. We also need to take care of manually destroying any popup we may create. Finally, the menu content creation in Menu.qml had to be tweaked since we shouldn't rely on the popup visibility anymore. Task-number: QTBUG-45182 Change-Id: I9f1155bbf74dd3353c6c4066a24abf1cd2c3a283 Reviewed-by: Caroline Chao Reviewed-by: J-P Nurmi --- src/controls/Private/EditMenu_base.qml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/controls/Private/EditMenu_base.qml') diff --git a/src/controls/Private/EditMenu_base.qml b/src/controls/Private/EditMenu_base.qml index b11cbf259..cda4d2b3f 100644 --- a/src/controls/Private/EditMenu_base.qml +++ b/src/controls/Private/EditMenu_base.qml @@ -102,9 +102,11 @@ Item { input.activate() if (control.menu) { - getMenuInstance().__dismissMenu(); + var menu = getMenuInstance(); + menu.__dismissMenu(); + menu.__destroyAllMenuPopups(); var menuPos = mapToItem(null, mouse.x, mouse.y) - getMenuInstance().__popup(Qt.rect(menuPos.x, menuPos.y, 0, 0), -1, MenuPrivate.EditMenu); + menu.__popup(Qt.rect(menuPos.x, menuPos.y, 0, 0), -1, MenuPrivate.EditMenu); } } } -- cgit v1.2.3