diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2022-09-30 12:34:52 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2022-10-10 09:57:40 +0200 |
commit | be104adfb5748e801e03f9d1b5fcc91ab74c5c4d (patch) | |
tree | 159c60e71ee3238439822e0803942e3934d242c4 /tests/auto/qml/qmltc | |
parent | 37730c6e1786e49083263c4deff5c37db7595cd1 (diff) |
qmltc: fix code generation for implicit components
Do not check if a type is implictly wrapped during visitation, as this
information is only made available by QQmlJSImportVisitor after(!) the
visit. Move this into the postvisit step of qmltc, and write some
internal documentation so this error will hopefully not be done again by
some qmltc contributor (e.g., me).
Now that implicit components are correctly recognized as such, they can
be compiled correctly and the c++-code generated by qmltc can again be
compiled.
Added also a test to see if all childrens of the repeater are correctly
instantiated.
Pick-to: 6.4
Fixes: QTBUG-107091
Change-Id: I8fce018b83316f8786ae5ca15e5af27c30bb1d37
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmltc')
-rw-r--r-- | tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml | 22 | ||||
-rw-r--r-- | tests/auto/qml/qmltc/tst_qmltc.cpp | 33 | ||||
-rw-r--r-- | tests/auto/qml/qmltc/tst_qmltc.h | 1 |
4 files changed, 57 insertions, 0 deletions
diff --git a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt index e9eee375e7..7712dcf992 100644 --- a/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt +++ b/tests/auto/qml/qmltc/QmltcTests/CMakeLists.txt @@ -100,6 +100,7 @@ set(qml_sources generalizedGroupedProperty.qml appendToQQmlListProperty.qml inlineComponents.qml + repeaterCrash.qml # support types: DefaultPropertySingleChild.qml diff --git a/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml b/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml new file mode 100644 index 0000000000..7c4dad5a4e --- /dev/null +++ b/tests/auto/qml/qmltc/QmltcTests/repeaterCrash.qml @@ -0,0 +1,22 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import QtQuick + +Item { + Item { + property string objName: "Child1" + } + + Repeater { + model: 4 + + Item { + property string objName: "Child" + (index + 1) + } + } + + Item { + property string objName: "Child6" + } +} diff --git a/tests/auto/qml/qmltc/tst_qmltc.cpp b/tests/auto/qml/qmltc/tst_qmltc.cpp index 942c18a44c..26265fcb46 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.cpp +++ b/tests/auto/qml/qmltc/tst_qmltc.cpp @@ -75,6 +75,7 @@ #include "generalizedgroupedproperty.h" #include "appendtoqqmllistproperty.h" #include "inlinecomponents.h" +#include "repeatercrash.h" #include "testprivateproperty.h" @@ -2461,6 +2462,38 @@ void tst_qmltc::translations() } } +void tst_qmltc::repeaterCrash() +{ + QQmlEngine e; + PREPEND_NAMESPACE(repeaterCrash) fromQmltc(&e); + + QQmlComponent component(&e, "qrc:/qt/qml/QmltcTests/repeaterCrash.qml"); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QScopedPointer<QQuickItem> fromEngine(qobject_cast<QQuickItem *>(component.create())); + QVERIFY(fromEngine); + + const int size = 7; + + const auto listFromEngine = fromEngine->childItems(); + const auto listFromQmltc = fromQmltc.childItems(); + + QCOMPARE(listFromEngine.size(), size); + QCOMPARE(listFromQmltc.size(), size); + + for (int i = 0; i < size; i++) { + // the repeater itself has no objName property + if (i == 5) + continue; + + const QVariant nameFromEngine = listFromEngine.at(i)->property("objName"); + const QVariant nameFromQmltc = listFromQmltc.at(i)->property("objName"); + + QVERIFY(nameFromEngine.isValid()); + QVERIFY(nameFromQmltc.isValid()); + QCOMPARE(nameFromQmltc.toString(), nameFromEngine.toString()); + } +} + void tst_qmltc::generalizedGroupedProperty() { QQmlEngine e; diff --git a/tests/auto/qml/qmltc/tst_qmltc.h b/tests/auto/qml/qmltc/tst_qmltc.h index 41f66f2a14..0eea63b0f2 100644 --- a/tests/auto/qml/qmltc/tst_qmltc.h +++ b/tests/auto/qml/qmltc/tst_qmltc.h @@ -84,6 +84,7 @@ private slots: void trickyPropertyChangeAndSignalHandlers(); void valueTypeListProperty(); void translations(); + void repeaterCrash(); void generalizedGroupedProperty(); void appendToQQmlListProperty(); void inlineComponents(); |