aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-11-10 13:19:03 +0100
committerUlf Hermann <ulf.hermann@qt.io>2025-11-11 19:27:24 +0100
commitb9e61c45f9d8d344732273e473738fb1082fcec7 (patch)
tree86f77a3b9c6581256162b5634c3d5295b8ea3986 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parente46378eb6eec85f4ea454778744c13a6e598107d (diff)
QmlCompiler: Fix rejection of dynamic properties in object literals
Since we early-return in a number of places, the condition needs to be checked first. Also, remove the dead code that tries to implement dynamic properties in object literals. Amends commits f839171eefbba670536262fa3b847d24bfdc627b and f47df45b4981d2d3eedfdbcf7574a7d2e2625627 which were mistaken in trying to support this case. Pick-to: 6.10 6.8 Fixes: QTBUG-141849 Change-Id: I34a6c47375b9e8fa1320259e3f335d304ce8e589 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index d4dc441a0e..0c585183e1 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -108,6 +108,7 @@ private slots:
void detachedReferences();
void dialogButtonBox();
void disappearingArrowFunction();
+ void dynamicObjectProperty();
void enumConversion();
void enumFromBadSingleton();
void enumLookup();
@@ -2004,6 +2005,18 @@ void tst_QmlCppCodegen::disappearingArrowFunction()
o->setObjectName("nonononononononono");
}
+void tst_QmlCppCodegen::dynamicObjectProperty()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/dynamicObjectProperty.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(o);
+
+ QCOMPARE(o->objectName(), u"6299"_s);
+}
+
void tst_QmlCppCodegen::enumConversion()
{
QQmlEngine engine;
@@ -6262,9 +6275,9 @@ void tst_QmlCppCodegen::variantMap()
QCOMPARE(o->property("r"), QVariant::fromValue(QRectF(12, 13, 14, 15)));
const QVariantMap expected = QVariantMap {
- { u"1"_s, QVariant::fromValue<std::nullptr_t>(nullptr) },
- { u"19"_s, QVariant::fromValue(u"19"_s) },
- { u"25"_s, QVariant() }
+ { u"a1"_s, QVariant::fromValue<std::nullptr_t>(nullptr) },
+ { u"a19"_s, QVariant::fromValue(u"19"_s) },
+ { u"a25"_s, QVariant() }
};
QCOMPARE(o->property("v").toMap(), expected);