summaryrefslogtreecommitdiff
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-04-17 14:12:05 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-04-25 16:53:00 +0200
commit365b781599993aef933228599eaeb6eb909d9a93 (patch)
tree5c8ef6bd3a8908d629e0939516a3c56efb7d1c18 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentd664cb4845f8b5c79ce34bb963312b18cce7452f (diff)
downloadqtdeclarative-365b781599993aef933228599eaeb6eb909d9a93.tar.gz
QmlCompiler: Implement ConvertThisToObject and basic DTZ
We know that 'this' is a QObject* since the metatypes stack frame mandates it. Whenever you pass 'this' to anything it's loaded from the special 'This' stack slot which then triggers a DTZ check. A DTZ check is a noop if we can prove that the type is statically known, though. In QmlCompiler, if we have a valid register content, then the register has been set in all code paths that lead to the instruction in question. Fixes: QTBUG-111439 Change-Id: I81d1cd140eea63f85628c3bef3a8f6db0a12096d 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.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 14cdee5501..6131224ef0 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -179,6 +179,7 @@ private slots:
void boolPointerMerge();
void mergedObjectReadWrite();
void listConversion();
+ void thisObject();
};
void tst_QmlCppCodegen::initTestCase()
@@ -3611,7 +3612,16 @@ void tst_QmlCppCodegen::listConversion()
QVariant::fromValue<qsizetype>(3),
QVariant::fromValue<Person *>(nullptr)
}));
+}
+void tst_QmlCppCodegen::thisObject()
+{
+ QQmlEngine e;
+ QQmlComponent c(&e, QUrl(u"qrc:/qt/qml/TestTypes/thisObject.qml"_s));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+ QCOMPARE(o->property("warned").value<QObject *>(), o.data());
}
QTEST_MAIN(tst_QmlCppCodegen)