summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-17 14:04:59 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-11-17 15:46:14 +0000
commit61db1507f30082c661c46410115ca74f74842ca7 (patch)
tree453a3ac408f8eeda25c3d9560b723c1ec3204f86
parent0f3f31334485dab7ff21a01c14f9411c05901f2b (diff)
downloadqtquickcontrols-61db1507f30082c661c46410115ca74f74842ca7.tar.gz
Fix proxy menu crash
Mobile-centric ApplicationWindowStyle implementations (Flat & Android) use a proxy menu to morph menubar items into a single menu button. The items are owned by the menubar and must not be deleted by the proxy menu. Otherwise, depending on the destruction order, the items would get deleted twice. Change-Id: I92d0c45fc3274574fd1edf34d8d3d081990f2727 Task-number: QTBUG-48927 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r--src/controls/Styles/Android/ApplicationWindowStyle.qml1
-rw-r--r--src/controls/qquickmenu.cpp8
-rw-r--r--src/controls/qquickmenu_p.h6
-rw-r--r--src/extras/Styles/Flat/ApplicationWindowStyle.qml1
4 files changed, 15 insertions, 1 deletions
diff --git a/src/controls/Styles/Android/ApplicationWindowStyle.qml b/src/controls/Styles/Android/ApplicationWindowStyle.qml
index 550d31a3..6f703845 100644
--- a/src/controls/Styles/Android/ApplicationWindowStyle.qml
+++ b/src/controls/Styles/Android/ApplicationWindowStyle.qml
@@ -104,6 +104,7 @@ QtObject {
Menu {
id: proxyMenu
+ __isProxy: true
items: control.menuBar ? control.menuBar.menus : []
}
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp
index bc9e7c5d..84f7b1aa 100644
--- a/src/controls/qquickmenu.cpp
+++ b/src/controls/qquickmenu.cpp
@@ -266,7 +266,8 @@ QQuickMenu::QQuickMenu(QObject *parent)
m_containersCount(0),
m_xOffset(0),
m_yOffset(0),
- m_triggerCount(0)
+ m_triggerCount(0),
+ m_proxy(false)
{
connect(this, SIGNAL(__textChanged()), this, SIGNAL(titleChanged()));
@@ -766,6 +767,11 @@ void QQuickMenu::clear()
m_containers.clear();
m_containersCount = 0;
+ // QTBUG-48927: a proxy menu (ApplicationWindowStyle.qml) must not
+ // delete its items, because they are owned by the menubar
+ if (m_proxy)
+ m_menuItems.clear();
+
while (!m_menuItems.empty())
delete m_menuItems.takeFirst();
m_itemsCount = 0;
diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h
index 1c51fe71..f49f6d62 100644
--- a/src/controls/qquickmenu_p.h
+++ b/src/controls/qquickmenu_p.h
@@ -70,6 +70,7 @@ class QQuickMenu : public QQuickMenuText
Q_PROPERTY(qreal __yOffset READ yOffset WRITE setYOffset)
Q_PROPERTY(QQuickAction *__action READ action CONSTANT)
Q_PROPERTY(QRect __popupGeometry READ popupGeometry NOTIFY __popupGeometryChanged)
+ Q_PROPERTY(bool __isProxy READ isProxy WRITE setProxy NOTIFY __proxyChanged)
Q_ENUMS(MenuType)
public:
@@ -106,6 +107,7 @@ Q_SIGNALS:
void __popupGeometryChanged();
void menuContentItemChanged();
void minimumWidthChanged();
+ void __proxyChanged();
public:
QQuickMenu(QObject *parent = 0);
@@ -142,6 +144,9 @@ public:
QRect popupGeometry() const;
+ bool isProxy() const { return m_proxy; }
+ void setProxy(bool proxy) { if (m_proxy != proxy) { m_proxy = proxy; emit __proxyChanged(); } }
+
void prepareItemTrigger(QQuickMenuItem *);
void concludeItemTrigger(QQuickMenuItem *);
void destroyMenuPopup();
@@ -196,6 +201,7 @@ private:
qreal m_yOffset;
QFont m_font;
int m_triggerCount;
+ bool m_proxy;
};
QT_END_NAMESPACE
diff --git a/src/extras/Styles/Flat/ApplicationWindowStyle.qml b/src/extras/Styles/Flat/ApplicationWindowStyle.qml
index 248e39d4..db714889 100644
--- a/src/extras/Styles/Flat/ApplicationWindowStyle.qml
+++ b/src/extras/Styles/Flat/ApplicationWindowStyle.qml
@@ -96,6 +96,7 @@ Base.ApplicationWindowStyle {
Menu {
id: proxyMenu
+ __isProxy: true
items: control.menuBar ? control.menuBar.menus : []
}