From 6c47fb0d80a720d44b6fafcd873dac2dafefcf0c Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 19 Sep 2014 19:34:05 +0200 Subject: Fix QQuickMenuBar::setNative() Due to evaluation order, menus can be appended to the default property before the native property is set => sync the items as appropriate. Technically it's now even possible to toggle between a native and non-native menubar even though it doesn't sound like a sane use-case. Change-Id: I513f133a085ffd980a4000afe2a992cb47b7448e Reviewed-by: Gabriel de Dietrich --- src/controls/qquickmenubar.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/controls/qquickmenubar.cpp') diff --git a/src/controls/qquickmenubar.cpp b/src/controls/qquickmenubar.cpp index d3503f89..33a1e9ef 100644 --- a/src/controls/qquickmenubar.cpp +++ b/src/controls/qquickmenubar.cpp @@ -85,9 +85,19 @@ void QQuickMenuBar::setNative(bool native) { bool wasNative = isNative(); if (native) { - if (!m_platformMenuBar) + if (!m_platformMenuBar) { m_platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); + if (m_platformMenuBar) { + m_platformMenuBar->handleReparent(m_parentWindow); + foreach (QQuickMenu *menu, m_menus) + m_platformMenuBar->insertMenu(menu->platformMenu(), 0 /* append */); + } + } } else { + if (m_platformMenuBar) { + foreach (QQuickMenu *menu, m_menus) + m_platformMenuBar->removeMenu(menu->platformMenu()); + } delete m_platformMenuBar; m_platformMenuBar = 0; } -- cgit v1.2.1