aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcontainer.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-08-16 10:36:19 +0200
committerMitch Curtis <mitch.curtis@qt.io>2018-10-02 09:04:56 +0000
commitd923dd467c1aeb3e195a09949b04862084002f88 (patch)
tree3d2ad3ab4d4989009195094bebd39276912dc5e1 /src/quicktemplates2/qquickcontainer.cpp
parente7213c0460788f49ec6c2204bfd5c0517699aa51 (diff)
MenuBar: ensure the correct delegates are used when created via Component
Don't add items until we're complete, as the delegate could change in the meantime. Instead, add them to contentData and create them when we're complete. A similar fix was already done for Menu in d5cb26bc. Task-number: QTBUG-67559 Change-Id: Idb43b7a69fcf1c1ad6396c73a3c090b92e460ab8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickcontainer.cpp')
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index 3dfefdc0..b3e7454b 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -334,6 +334,21 @@ void QQuickContainerPrivate::reorderItems()
}
}
+// Helper function needed for derived classes such as QQuickMenuBarPrivate.
+void QQuickContainerPrivate::addObject(QObject *obj)
+{
+ Q_Q(QQuickContainer);
+ QQuickItem *item = qobject_cast<QQuickItem *>(obj);
+ if (item) {
+ if (QQuickItemPrivate::get(item)->isTransparentForPositioner())
+ item->setParentItem(effectiveContentItem(contentItem));
+ else if (contentModel->indexOf(item, nullptr) == -1)
+ q->addItem(item);
+ } else {
+ contentData.append(obj);
+ }
+}
+
void QQuickContainerPrivate::_q_currentIndexChanged()
{
Q_Q(QQuickContainer);
@@ -375,15 +390,7 @@ void QQuickContainerPrivate::contentData_append(QQmlListProperty<QObject> *prop,
{
QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
QQuickContainerPrivate *p = QQuickContainerPrivate::get(q);
- QQuickItem *item = qobject_cast<QQuickItem *>(obj);
- if (item) {
- if (QQuickItemPrivate::get(item)->isTransparentForPositioner())
- item->setParentItem(effectiveContentItem(p->contentItem));
- else if (p->contentModel->indexOf(item, nullptr) == -1)
- q->addItem(item);
- } else {
- p->contentData.append(obj);
- }
+ p->addObject(obj);
}
int QQuickContainerPrivate::contentData_count(QQmlListProperty<QObject> *prop)