From 2d016a2653c59f10a57dc1903b817f71d16d0622 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Aug 2025 11:43:55 +0200 Subject: QtQml: Mark values on the AOT-compiled stack during gc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keep them in a special generated struct with virtual method that gets called from the GC for each frame. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-139059 Change-Id: I81bcbeab6531e174a5207d03f57d241461ae9ba3 Reviewed-by: Olivier De Cannière --- tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp') diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index 7e116e9d6f..243b6b1296 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -72,6 +72,7 @@ private slots: void callContextPropertyLookupResult(); void callObjectLookupOnNull(); void callWithSpread(); + void collectGarbageDuringAotCode(); void colorAsVariant(); void colorString(); void compareOriginals(); @@ -1100,6 +1101,25 @@ void tst_QmlCppCodegen::callWithSpread() QVERIFY(!o.isNull()); } +void tst_QmlCppCodegen::collectGarbageDuringAotCode() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/collector.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer o(c.create()); + QVERIFY(!o.isNull()); + + QObject *inner = o->property("o").value(); + QVERIFY(inner); + QCOMPARE(inner->objectName(), u"dynamic"_s); + + inner = o->property("o2").value(); + QVERIFY(inner); + QCOMPARE(inner->objectName(), u"dynamic"_s); + + QCOMPARE(o->property("gcRun").toInt(), 1); +} + void tst_QmlCppCodegen::colorAsVariant() { QQmlEngine engine; -- cgit v1.2.3