diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-05-28 08:41:31 +0200 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2020-05-29 11:12:26 +0200 |
commit | 7640c9988f37e49e12f56be7a30ea97170922b9f (patch) | |
tree | adfa05b474203520a4b21b2e3372b77f53c67335 /src | |
parent | 0e18524a84d2aae65c54edc676d8ad7348f7d61c (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
Pick-to: 5.15
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/platform/qquickplatformmenuitem.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp index 45e6ba2d..3a717047 100644 --- a/src/imports/platform/qquickplatformmenuitem.cpp +++ b/src/imports/platform/qquickplatformmenuitem.cpp @@ -166,8 +166,13 @@ void QQuickPlatformMenuItem::sync() m_handle->setText(m_text); m_handle->setFont(m_font); 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; |