diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-12-09 08:06:18 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-12-10 06:52:35 +0100 |
commit | 8326ff2ac1472415b82734946435d3e7e75d522b (patch) | |
tree | ccafa1912fb16d092ca1645975ca11324cba550d /tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp | |
parent | cd5d62e9997c71e2105d571f681777c5a59c3ef1 (diff) |
Instantiator: don't interfere with delegates that assign parents
[ChangeLog][QtQml][Instantiator] Instantiator now avoids re-assigning a
delegate object's parent to itself if it was already set; thus, you can
now declare a parent assignment.
Task-number: QTBUG-64546
Task-number: QTBUG-84730
Change-Id: I7d95fa76e71c363b4cb5b7a512c2e984488c8af4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp')
-rw-r--r-- | tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp index 4c6c84a9d2..a0ab2cda5b 100644 --- a/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp +++ b/tests/auto/qml/qqmlinstantiator/tst_qqmlinstantiator.cpp @@ -56,6 +56,8 @@ private slots: void asynchronous_data(); void asynchronous(); + + void handlerWithParent(); }; tst_qqmlinstantiator::tst_qqmlinstantiator() @@ -276,6 +278,19 @@ void tst_qqmlinstantiator::asynchronous() } } +void tst_qqmlinstantiator::handlerWithParent() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("handlerWithParent.qml")); + QObject *rootObject = component.create(); + QVERIFY(rootObject != nullptr); + const auto handlers = rootObject->findChildren<QObject *>("pointHandler"); + QCOMPARE(handlers.count(), 2); + for (const auto *h : handlers) { + QCOMPARE(h->parent(), rootObject); + } +} + QTEST_MAIN(tst_qqmlinstantiator) #include "tst_qqmlinstantiator.moc" |