aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-07-27 11:42:39 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-08-08 15:12:46 +0200
commitd07744ef5de723b9d456596adad2d68e94b2cd47 (patch)
tree2a53e34fd2067db3c56fd9c8d005460a6c571d5f /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parent30dbb36fc3e52dbcfac99c4b0101da7ad882860b (diff)
QmlCompiler: Fix SetLookup on shadowable properties
If we are procedurally setting a shadowable property, the read register for the value will be converted to var. We can therefore not just retrieve the property type again in the code generator to determine what we have to do. What we actually need is the information on the original scope type of the lookup. We need to know what exactly the base type was supposed to be. To that effect, store the scope of the target for each conversion in QQmlJSRegisterContent. We need to circumvent the questionable optimization of "deduplicating" functions that certain compilers exhibit, like we do for the getters. Pick-to: 6.6 Fixes: QTBUG-115526 Change-Id: I361f2e46e39ece7892df72ae13ec756f9aec4adf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index db1ae4f08b..273571d225 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -167,6 +167,7 @@ private slots:
void scopeObjectDestruction();
void scopeVsObject();
void sequenceToIterable();
+ void setLookupConversion();
void shadowedMethod();
void shifts();
void signalHandler();
@@ -3460,6 +3461,18 @@ void tst_QmlCppCodegen::sequenceToIterable()
}
}
+void tst_QmlCppCodegen::setLookupConversion()
+{
+ QQmlEngine e;
+ QQmlComponent c(&e, QUrl(u"qrc:/qt/qml/TestTypes/setLookupConversion.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+ QVERIFY(o->objectName().isEmpty());
+ QMetaObject::invokeMethod(o.data(), "t");
+ QCOMPARE(o->objectName(), u"a"_s);
+}
+
void tst_QmlCppCodegen::shadowedMethod()
{
QQmlEngine e;