diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-09-24 19:56:23 +0200 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-10-01 09:07:59 +0000 |
commit | b27a01a86e614207025e569926d0c419857e8965 (patch) | |
tree | 9d3dc7b339f3bc4ed7d2dcdaca17f091376b5aca /src/controls/qquickmenu_p.h | |
parent | 79092d8ab8f5c02c5d880d33f9869c034f0f933d (diff) | |
download | qtquickcontrols-b27a01a86e614207025e569926d0c419857e8965.tar.gz |
Menus: Clean popup hide and destroy logic
When a menu popup gets closed it usually needs to be destroyed right away
since we don't recycle its contents. There is an exception, however, and
it's when he user triggers a menu item.
In this case, we need to proceed in three steps. First, we hide the menu
popup, then we emit the triggered signal, and when that one returns, the
menu contents can be disposed. If we did all in a single step, we may end
up with a crash since we don't support deleting a QtQuick item while it's
running a signal handler. Delayed deletions don't work either in the case
when the triggered handler ends up running the event loop.
Task-number: QTBUG-45182
Task-number: QTBUG-47682
Task-number: QTBUG-48382
Change-Id: Ic39717e09f38df602f641250cd81cf4931863db6
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/controls/qquickmenu_p.h')
-rw-r--r-- | src/controls/qquickmenu_p.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h index a16e720a..a626179a 100644 --- a/src/controls/qquickmenu_p.h +++ b/src/controls/qquickmenu_p.h @@ -89,10 +89,10 @@ public: Q_INVOKABLE void __popup(const QRectF &targetRect, int atItemIndex = -1, MenuType menuType = DefaultMenu); public Q_SLOTS: - void __closeMenu(); void __dismissMenu(); - void __destroyMenuPopup(); - void __destroyAllMenuPopups(); + + void __closeAndDestroy(); + void __dismissAndDestroy(); Q_SIGNALS: void itemsChanged(); @@ -142,11 +142,17 @@ public: QRect popupGeometry() const; + void prepareItemTrigger(QQuickMenuItem *); + void concludeItemTrigger(QQuickMenuItem *); + void destroyMenuPopup(); + void destroyAllMenuPopups(); + protected Q_SLOTS: void updateSelectedIndex(); void setMenuContentItem(QQuickItem *); void setPopupVisible(bool); + void hideMenu(); void clearPopupWindow(); void updateText(); @@ -189,6 +195,7 @@ private: qreal m_xOffset; qreal m_yOffset; QFont m_font; + int m_triggerCount; }; QT_END_NAMESPACE |