diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-07-17 16:37:46 +0200 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-07-27 11:02:36 +0000 |
commit | 27390b35746f3f5390e26471f99d31762a1ad548 (patch) | |
tree | 4eb93c6d89eab0a39fa53ebeca31d187c9658505 | |
parent | abc2ec74e9131cdae1bf9a458dfe9a2ef46b889c (diff) | |
download | qtquickcontrols-27390b35746f3f5390e26471f99d31762a1ad548.tar.gz |
QQuickMenuBar: Remove native menus from native menubar on destruction
The native menus are deleted because they're usually children
of the menubar. But we still keep references in QCocoaMenuBar
until we manually remove those form the menu list.
Change-Id: I1651852b6ebc578ca308d69299de4c12764f7363
Task-number: QTBUG-47233
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r-- | src/controls/qquickmenubar.cpp | 11 | ||||
-rw-r--r-- | src/controls/qquickmenubar_p.h | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/controls/qquickmenubar.cpp b/src/controls/qquickmenubar.cpp index 52f2d1eb..efec6510 100644 --- a/src/controls/qquickmenubar.cpp +++ b/src/controls/qquickmenubar.cpp @@ -72,6 +72,8 @@ QQuickMenuBar::QQuickMenuBar(QObject *parent) QQuickMenuBar::~QQuickMenuBar() { + if (isNative()) + setNativeNoNotify(false); } QQmlListProperty<QQuickMenu> QQuickMenuBar::menus() @@ -87,6 +89,13 @@ bool QQuickMenuBar::isNative() const void QQuickMenuBar::setNative(bool native) { bool wasNative = isNative(); + setNativeNoNotify(native); + if (isNative() != wasNative) + emit nativeChanged(); +} + +void QQuickMenuBar::setNativeNoNotify(bool native) +{ if (native) { if (!m_platformMenuBar) { m_platformMenuBar = QGuiApplicationPrivate::platformTheme()->createPlatformMenuBar(); @@ -104,8 +113,6 @@ void QQuickMenuBar::setNative(bool native) delete m_platformMenuBar; m_platformMenuBar = 0; } - if (isNative() != wasNative) - emit nativeChanged(); } void QQuickMenuBar::setContentItem(QQuickItem *item) diff --git a/src/controls/qquickmenubar_p.h b/src/controls/qquickmenubar_p.h index d0bbedce..83166d77 100644 --- a/src/controls/qquickmenubar_p.h +++ b/src/controls/qquickmenubar_p.h @@ -81,6 +81,7 @@ public: QPlatformMenuBar *platformMenuBar() const { return m_platformMenuBar; } private: + void setNativeNoNotify(bool native); static void append_menu(QQmlListProperty<QQuickMenu> *list, QQuickMenu *menu); static int count_menu(QQmlListProperty<QQuickMenu> *list); static QQuickMenu *at_menu(QQmlListProperty<QQuickMenu> *list, int index); |