diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-12-15 17:12:56 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-12-20 13:05:14 +0100 |
commit | 9b87e051cdbe1c8507071e2834b069b808bc1e04 (patch) | |
tree | 98bf567f7615d0c70a7d7c8bf6d39964dd5ee403 /tests | |
parent | 40f223c6343bd2f925d9268f42674e92911ea368 (diff) |
QtQml: Do not poison the type registry with unfinished enums
If a composite type is not ready, yet, and we request its enums, we
should not cache the result. To facilitate this, deduplicate the
surrounding code and centralize the call to initEnums().
Pick-to: 6.7
Fixes: QTBUG-120084
Change-Id: I8386a3b44010a39470e886e93c5c64bfedac0b95
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnumSelfReference.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnumSelfReference.qml b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnumSelfReference.qml new file mode 100644 index 0000000000..0ec43bf7aa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/CompositeTypeWithEnumSelfReference.qml @@ -0,0 +1,8 @@ +import QtQml +import Test + +QtObject { + enum A { B, C, D } + property int e: CompositeTypeWithEnumSelfReference.C + property int f: CompositeTypeWithEnumSelfReference.A.D +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index a9c508c73d..0f02182f45 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -3894,6 +3894,7 @@ void tst_qqmllanguage::initTestCase() qmlRegisterType(testFileUrl("invalidRoot.1.qml"), "Test", 1, 0, "RegisteredCompositeType3"); qmlRegisterType(testFileUrl("CompositeTypeWithEnum.qml"), "Test", 1, 0, "RegisteredCompositeTypeWithEnum"); qmlRegisterType(testFileUrl("CompositeTypeWithAttachedProperty.qml"), "Test", 1, 0, "RegisteredCompositeTypeWithAttachedProperty"); + qmlRegisterType(testFileUrl("CompositeTypeWithEnumSelfReference.qml"), "Test", 1, 0, "CompositeTypeWithEnumSelfReference"); // Registering the TestType class in other modules should have no adverse effects qmlRegisterType<TestType>("org.qtproject.TestPre", 1, 0, "Test"); @@ -4069,6 +4070,17 @@ void tst_qqmllanguage::registeredCompositeTypeWithEnum() QCOMPARE(o->property("enumValue0").toInt(), static_cast<int>(MyCompositeBaseType::EnumValue0)); QCOMPARE(o->property("enumValue42").toInt(), static_cast<int>(MyCompositeBaseType::EnumValue42)); QCOMPARE(o->property("enumValue15").toInt(), static_cast<int>(MyCompositeBaseType::ScopedCompositeEnum::EnumValue15)); + + { + QQmlComponent component(&engine); + component.setData("import Test\nCompositeTypeWithEnumSelfReference {}", QUrl()); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(o != nullptr); + + QCOMPARE(o->property("e").toInt(), 1); + QCOMPARE(o->property("f").toInt(), 2); + } } // QTBUG-43581 |