diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-11-22 10:25:27 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-11-22 12:15:15 +0100 |
commit | 662ab7ebdad0e6c32278f2fcf9a5e43a11681b09 (patch) | |
tree | aa3aced53fb3bec4c46b0d7a195938556ee4536c /tests/auto/quick/qquickrepeater | |
parent | 744e77b841878fb017c0f2d60607090008f28180 (diff) |
QQmlDelegateModel: Set extraObject only if required properties given
Otherwise we would set the same object as extraObject and as
contextObject. That spells trouble when tearing down the context.
Fixes: QTBUG-79958
Change-Id: I97fd0bf111304d06cff35eda46d4b4c6eefdaccc
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickrepeater')
-rw-r--r-- | tests/auto/quick/qquickrepeater/data/contextProperty.qml | 13 | ||||
-rw-r--r-- | tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp | 24 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickrepeater/data/contextProperty.qml b/tests/auto/quick/qquickrepeater/data/contextProperty.qml new file mode 100644 index 0000000000..44e76f474f --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/contextProperty.qml @@ -0,0 +1,13 @@ +import QtQuick 2.14 + +Item { + Column { + Repeater { + model: ["apples", "oranges", "pears"] + Text { + id: txt + text: modelData + index + } + } + } +} diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp index ccfef63902..33b8742170 100644 --- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp +++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp @@ -81,6 +81,7 @@ private slots: void package(); void ownership(); void requiredProperties(); + void contextProperties(); }; class TestObject : public QObject @@ -1131,6 +1132,29 @@ void tst_QQuickRepeater::requiredProperties() QVERIFY(o); } +void tst_QQuickRepeater::contextProperties() +{ + QQmlEngine engine; + + QQmlComponent component(&engine, testFileUrl("contextProperty.qml")); + QScopedPointer<QObject> o {component.create()}; + QVERIFY(o); + + auto *root = qobject_cast<QQuickItem *>(o.get()); + QVERIFY(root); + + QQueue<QQuickItem *> items; + items.append(root); + + while (!items.isEmpty()) { + QQuickItem *item = items.dequeue(); + QQmlContextData *data = QQmlContextData::get(qmlContext(item)); + QVERIFY(!data->hasExtraObject); + for (QQuickItem *child : item->childItems()) + items.enqueue(child); + } +} + QTEST_MAIN(tst_QQuickRepeater) #include "tst_qquickrepeater.moc" |