diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-11-14 11:13:15 +0100 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2018-11-15 16:08:46 +0000 |
commit | d3545dbdfdb30e310c6c962ba92f4fdf57354666 (patch) | |
tree | e56e0a167ee50cb104cb28ed7e6ae730512c55ca /src/quicktemplates2/qquickmenubar.cpp | |
parent | 0b5f60148f4992381ae79f399b243ecb2774d2ba (diff) |
Revert all Menu delegate patchesv5.12.0-rc2v5.12.0-rc1v5.12.0
This reverts the following commits:
d5cb26bc56a3b6f6e99c88654d4f7a65f43551ac - Menu: ensure the correct delegates are used when created via Component
d923dd467c1aeb3e195a09949b04862084002f88 - MenuBar: ensure the correct delegates are used when created via Component
d56c193eb4ceb640611d66f22e1f26aae91cd7d1 - QQuickPopupPositioner: avoid adding duplicate item change listeners
567a2de8cd493aabe0055d6dbc367b39447e70dd - Stabilize tst_qquickmenubar
953fbac6131823e4fce0eb4707a854469c4c04ff - Fix Instantiator-created MenuItems disappearing
936d31179d44220571ded15840bedeccb581c83b - tst_qquickmenu: add a test for MenuItems before and after a Repeater
fc1832810f6c09505d9413685ed0b2d6295bea4a - QQuickMenuBar: fix menu not opening
The fix for QTBUG-67559 has caused lots of issues, with the latest being a
crash right before the 5.12 release. The bug that they fix is a P2,
so it's not worth the hassle. The patches might be able to be resubmitted
to dev after the crash is fixed.
Change-Id: Ic192c7a302176bcdb2503b636b3462b10898a2ba
Fixes: QTBUG-71770
Reviewed-by: J-P Nurmi <jpnurmi@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickmenubar.cpp')
-rw-r--r-- | src/quicktemplates2/qquickmenubar.cpp | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp index 9be9ee09..6016e70d 100644 --- a/src/quicktemplates2/qquickmenubar.cpp +++ b/src/quicktemplates2/qquickmenubar.cpp @@ -76,26 +76,7 @@ QT_BEGIN_NAMESPACE {Focus Management in Qt Quick Controls 2} */ -void QQuickMenuBarPrivate::createItems() -{ - // removeItem() will remove stuff from contentData, so we have to make a copy of it. - const auto originalContentData = QQuickContainerPrivate::contentData; - // Sanity check that there aren't any items we don't know about. - Q_ASSERT(contentModel->count() == 0); - - for (QObject *object : originalContentData) { - if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(object)) { - // It's a QQuickMenu; create a QQuickMenuBarItem for it. - QQuickItem *menuItem = createItem(menu); - addObject(menuItem); - } else if (qobject_cast<QQuickMenuBarItem *>(object)) { - addObject(object); - } - // If it's neither, skip it because we don't care about it. - } -} - -QQuickItem *QQuickMenuBarPrivate::beginCreateItem(QQuickMenu *menu) +QQuickItem *QQuickMenuBarPrivate::beginCreateItem() { Q_Q(QQuickMenuBar); if (!delegate) @@ -115,8 +96,6 @@ QQuickItem *QQuickMenuBarPrivate::beginCreateItem(QQuickMenu *menu) return nullptr; } - if (QQuickMenuBarItem *menuBarItem = qobject_cast<QQuickMenuBarItem *>(item)) - menuBarItem->setMenu(menu); item->setParentItem(q); QQml_setParent_noEvent(item, q); @@ -133,7 +112,9 @@ void QQuickMenuBarPrivate::completeCreateItem() QQuickItem *QQuickMenuBarPrivate::createItem(QQuickMenu *menu) { - QQuickItem *item = beginCreateItem(menu); + QQuickItem *item = beginCreateItem(); + if (QQuickMenuBarItem *menuBarItem = qobject_cast<QQuickMenuBarItem *>(item)) + menuBarItem->setMenu(menu); completeCreateItem(); return item; } @@ -273,18 +254,9 @@ void QQuickMenuBarPrivate::itemImplicitHeightChanged(QQuickItem *item) void QQuickMenuBarPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObject *obj) { QQuickMenuBar *menuBar = static_cast<QQuickMenuBar *>(prop->object); - QQuickMenuBarPrivate *menuBarPrivate = QQuickMenuBarPrivate::get(menuBar); - if (!menuBarPrivate->componentComplete) { - // Don't add items until we're complete, as the delegate could change in the meantime. - // We'll add it to contentData and create it when we're complete. - menuBarPrivate->QQuickContainerPrivate::contentData.append(obj); - return; - } - - if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj)) { - QQuickItem *menuItem = menuBarPrivate->createItem(menu); - menuBarPrivate->addObject(menuItem); - } + if (QQuickMenu *menu = qobject_cast<QQuickMenu *>(obj)) + obj = QQuickMenuBarPrivate::get(menuBar)->createItem(menu); + QQuickContainerPrivate::contentData_append(prop, obj); } void QQuickMenuBarPrivate::menus_append(QQmlListProperty<QQuickMenu> *prop, QQuickMenu *obj) @@ -482,13 +454,6 @@ QQmlListProperty<QObject> QQuickMenuBarPrivate::contentData() QQuickContainerPrivate::contentData_clear); } -void QQuickMenuBar::componentComplete() -{ - Q_D(QQuickMenuBar); - QQuickContainer::componentComplete(); - d->createItems(); -} - bool QQuickMenuBar::eventFilter(QObject *object, QEvent *event) { return QObject::eventFilter(object, event); |