diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-01 11:42:33 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-02 10:07:40 +0200 |
commit | 8ea96460198bea744a3583a714d2cc042d8403ab (patch) | |
tree | 01e6bda83772d1167ddd935497eb4f1503248970 /tests | |
parent | 15efc5c32369f5852c7f83696fe0d21f6d338972 (diff) |
QmlCompiler: Don't crash when trying to resolve null list types
If the element type is unknown the list type is also unknown. This will
happen if we cannot resolve the type.
Fixes: QTBUG-103920
Change-Id: If1b05d99a1e64961981b5adb3974a51c11e776d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/data/invisibleListElementType.qml | 11 | ||||
-rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 27 |
3 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt index e5d9dc5351..7266ad0b5a 100644 --- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt +++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt @@ -86,6 +86,7 @@ set(qml_files infinities.qml invisibleBase.qml invisibleTypes.qml + invisibleListElementType.qml intEnumCompare.qml intOverflow.qml interactive.qml diff --git a/tests/auto/qml/qmlcppcodegen/data/invisibleListElementType.qml b/tests/auto/qml/qmlcppcodegen/data/invisibleListElementType.qml new file mode 100644 index 0000000000..1be05552f7 --- /dev/null +++ b/tests/auto/qml/qmlcppcodegen/data/invisibleListElementType.qml @@ -0,0 +1,11 @@ +import QtQml +import Invisible + +QtObject { + id: root + property list<InvisibleListElement> customList + + property QtObject a: QtObject { + property var x: root.customList + } +} diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 84c5ad2deb..54be586e24 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -136,6 +136,7 @@ private slots: void invalidPropertyType(); void valueTypeLists(); void boundComponents(); + void invisibleListElementType(); }; void tst_QmlCppCodegen::simpleBinding() @@ -2162,6 +2163,32 @@ void tst_QmlCppCodegen::boundComponents() QCOMPARE(c2o->objectName(), u"bar12"_s); } +class InvisibleListElementType : public QObject +{ + Q_OBJECT +public: + InvisibleListElementType(QObject *parent = nullptr) : QObject(parent) {} +}; + +void tst_QmlCppCodegen::invisibleListElementType() +{ + qmlRegisterType<InvisibleListElementType>("Invisible", 1, 0, "InvisibleListElement"); + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/TestTypes/invisibleListElementType.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + + QObject *a = o->property("a").value<QObject *>(); + QVERIFY(a); + + const QVariant x = a->property("x"); + QCOMPARE(x.metaType(), QMetaType::fromType<QQmlListReference>()); + const QQmlListReference ref = x.value<QQmlListReference>(); + QVERIFY(ref.isValid()); + QCOMPARE(ref.size(), 0); +} + void tst_QmlCppCodegen::runInterpreted() { #ifdef Q_OS_ANDROID |