diff options
authorAndy Shaw <andy.shaw@qt.io>2020-05-28 08:41:31 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-05-29 09:58:32 +0000
commitd5a01cdf6e762f510e0b70e3be95998f16ebaf40 (patch)
parent7f820ab2949dd6f0595b916192279745aafe4d71 (diff)
Sync the QQuickPlatformMenu so it has a handle ready when its a sub menu
When dynamically creating a menu, it will be parented after it has created the handle the first time around. Therefore it loses the original handle and does not get a new one when needed. So by calling sync() before it is set as the sub menu then it can get a handle created if necessary in time. Change-Id: Ia39f49f99758802dd19ff1df478b05ac5e403ea8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 7640c9988f37e49e12f56be7a30ea97170922b9f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
1 files changed, 7 insertions, 2 deletions
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp
index a1f17aa4..44f38e0f 100644
--- a/src/imports/platform/qquickplatformmenuitem.cpp
+++ b/src/imports/platform/qquickplatformmenuitem.cpp
@@ -166,8 +166,13 @@ void QQuickPlatformMenuItem::sync()
m_handle->setHasExclusiveGroup(m_group && m_group->isExclusive());
- if (m_subMenu && m_subMenu->handle())
- m_handle->setMenu(m_subMenu->handle());
+ if (m_subMenu) {
+ // Sync first as dynamically created menus may need to get the
+ // handle recreated
+ m_subMenu->sync();
+ if (m_subMenu->handle())
+ m_handle->setMenu(m_subMenu->handle());
+ }
#if QT_CONFIG(shortcut)
QKeySequence sequence;