public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/qt6-qtdeclarative] epel9: QtQml: Do not clear objects propertyCaches on last GC run
@ 2026-10-08 17:40 Jan Grulich
0 siblings, 0 replies; 2+ messages in thread
From: Jan Grulich @ 2026-10-08 17:40 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/qt6-qtdeclarative
Branch : epel9
Commit : 2a047e7226c231b2188c29fc2391398cf39eede1
Author : Jan Grulich <jgrulich@redhat.com>
Date : 2026-01-14T08:13:14+01:00
Stats : +138/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/qt6-qtdeclarative/c/2a047e7226c231b2188c29fc2391398cf39eede1?branch=epel9
Log:
QtQml: Do not clear objects propertyCaches on last GC run
---
diff --git a/qt6-qtdeclarative.spec b/qt6-qtdeclarative.spec
index c1ebcb7..0bf2493 100644
--- a/qt6-qtdeclarative.spec
+++ b/qt6-qtdeclarative.spec
@@ -16,7 +16,7 @@
Summary: Qt6 - QtDeclarative component
Name: qt6-%{qt_module}
Version: 6.10.1
-Release: 2%{?dist}
+Release: 3%{?dist}
License: LGPL-3.0-only OR GPL-3.0-only WITH Qt-GPL-exception-1.0
Url: http://www.qt.io
@@ -37,6 +37,7 @@ Source5: qv4global_p-multilib.h
# https://codereview.qt-project.org/c/qt/qtdeclarative/+/678924
Patch0: qtdeclarative-quickshapes-make-module-public.patch
Patch1: qtdeclarative-qtqml-invalidate-fallback-lookups-after-each-call-from-aot-code.patch
+Patch2: qtdeclarative-qtqml-do-not-clear-objects-propertycaches-on-last-gc-run.patch
## upstreamable patches
@@ -737,6 +738,9 @@ make check -k -C tests ||:
%endif
%changelog
+* Wed Jan 14 2026 Jan Grulich <jgrulich@redhat.com> - 6.10.1-3
+- QtQml: Do not clear objects propertyCaches on last GC run
+
* Tue Dec 09 2025 Jan Grulich <jgrulich@redhat.com> - 6.10.1-2
- QtQml: Invalidate fallback lookups after each call from AOT code
diff --git a/qtdeclarative-qtqml-do-not-clear-objects-propertycaches-on-last-gc-run.patch b/qtdeclarative-qtqml-do-not-clear-objects-propertycaches-on-last-gc-run.patch
new file mode 100644
index 0000000..9ce08be
--- /dev/null
+++ b/qtdeclarative-qtqml-do-not-clear-objects-propertycaches-on-last-gc-run.patch
@@ -0,0 +1,133 @@
+From dc2358e98b8ddab532866a403ffc09d1162ad0f9 Mon Sep 17 00:00:00 2001
+From: Ulf Hermann <ulf.hermann@qt.io>
+Date: Tue, 13 Jan 2026 11:53:27 +0100
+Subject: [PATCH] QtQml: Do not clear objects' propertyCaches on last GC run
+
+The property caches are not specific to the engine. The same object may
+be exposed to other engines and still require its property cache. When
+the clearing of the property caches on engine destruction was
+introduced, the property caches were still engine-specific and we had no
+choice but to clear them. Otherwise any further access would lead to a
+dereference of a dangling pointer.
+
+Furthermore, when clearing the JS wrapper for a QObject, check if it's
+actually the wrapper being deleted. We don't want to clear some other
+engine's wrapper.
+
+Amends commit 749a7212e903d8e8c6f256edb1836b9449cc7fe1.
+Amends commit c6b2dd879d02b21b18f80faab541f8f04286685a.
+
+Pick-to: 6.11 6.10
+Fixes: QTBUG-142514
+Change-Id: I40bb1aeca65225d56cb1d2ff498f5f1722216a70
+Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
+---
+
+diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index a8dfd50..e61867b 100644
+--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1583,10 +1583,9 @@
+ o->deleteLater();
+ } else {
+ // If the object is C++-owned, we still have to release the weak reference we have
+- // to it.
+- ddata->jsWrapper.clear();
+- if (lastCall && ddata->propertyCache)
+- ddata->propertyCache.reset();
++ // to it. If the "main" wrapper is not ours, we should leave it alone, though.
++ if (ddata->jsWrapper.as<QObjectWrapper>() == this)
++ ddata->jsWrapper.clear();
+ }
+ }
+ }
+diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index b56b241..11bc62e 100644
+--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -1119,7 +1119,7 @@
+ engine.newQObject(obj.data());
+ QVERIFY(QQmlData::get(obj.data())->propertyCache);
+ }
+- QVERIFY(!QQmlData::get(obj.data())->propertyCache);
++ QVERIFY(QQmlData::get(obj.data())->propertyCache);
+ }
+
+ void tst_QJSEngine::newQMetaObject() {
+diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+index 88cc102..8949d00 100644
+--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
++++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+@@ -326,6 +326,7 @@
+ stringLength.qml
+ stringToByteArray.qml
+ structuredValueType.qml
++ multiEnginePropertyCache.qml
+ takenumber.qml
+ testlogger.js
+ text.qml
+diff --git a/tests/auto/qml/qmlcppcodegen/data/multiEnginePropertyCache.qml b/tests/auto/qml/qmlcppcodegen/data/multiEnginePropertyCache.qml
+new file mode 100644
+index 0000000..222b2f8
+--- /dev/null
++++ b/tests/auto/qml/qmlcppcodegen/data/multiEnginePropertyCache.qml
+@@ -0,0 +1,20 @@
++pragma Strict
++import QtQml
++
++QtObject {
++ id: root
++
++ property int foo: 0
++ onFooChanged: root.close1()
++
++ property int bar: 0
++ onBarChanged: close2()
++
++ function close1() {
++ console.log("close1")
++ }
++
++ function close2() {
++ console.log("close2")
++ }
++}
+diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+index 3ce5627..8d98c02 100644
+--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
++++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+@@ -280,6 +280,7 @@
+ void stringLength();
+ void stringToByteArray();
+ void structuredValueType();
++ void multiEnginePropertyCache();
+ void takeNumbers();
+ void takeNumbers_data();
+ void testIsnan();
+@@ -5795,6 +5796,26 @@
+ QCOMPARE(o->property("w2").value<WeatherModelUrl>(), w2);
+ }
+
++void tst_QmlCppCodegen::multiEnginePropertyCache()
++{
++ QQmlEngine engine;
++ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/multiEnginePropertyCache.qml"_s));
++ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
++ std::unique_ptr<QObject> o(c.create());
++ QVERIFY(o);
++
++ {
++ QJSEngine other;
++ other.newQObject(o.get());
++ }
++
++ QTest::ignoreMessage(QtDebugMsg, "close1");
++ o->setProperty("foo", 1);
++
++ QTest::ignoreMessage(QtDebugMsg, "close2");
++ o->setProperty("bar", 2);
++}
++
+ void tst_QmlCppCodegen::takeNumbers()
+ {
+ QFETCH(QByteArray, method);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [rpms/qt6-qtdeclarative] epel9: QtQml: Do not clear objects propertyCaches on last GC run
@ 2026-10-08 17:40 Jan Grulich
0 siblings, 0 replies; 2+ messages in thread
From: Jan Grulich @ 2026-10-08 17:40 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/qt6-qtdeclarative
Branch : epel9
Commit : a6758630e758df68b4c1a725e6d1c52177eb03a8
Author : Jan Grulich <jgrulich@redhat.com>
Date : 2026-02-19T08:57:50+01:00
Stats : +138/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/qt6-qtdeclarative/c/a6758630e758df68b4c1a725e6d1c52177eb03a8?branch=epel9
Log:
QtQml: Do not clear objects propertyCaches on last GC run
---
diff --git a/qt6-qtdeclarative.spec b/qt6-qtdeclarative.spec
index c7a7721..d58823c 100644
--- a/qt6-qtdeclarative.spec
+++ b/qt6-qtdeclarative.spec
@@ -16,7 +16,7 @@
Summary: Qt6 - QtDeclarative component
Name: qt6-%{qt_module}
Version: 6.10.2
-Release: 1%{?dist}
+Release: 2%{?dist}
License: LGPL-3.0-only OR GPL-3.0-only WITH Qt-GPL-exception-1.0
Url: http://www.qt.io
@@ -36,6 +36,7 @@ Source5: qv4global_p-multilib.h
## upstream patches
# https://codereview.qt-project.org/c/qt/qtdeclarative/+/678924
Patch0: qtdeclarative-quickshapes-make-module-public.patch
+Patch1: qtdeclarative-qtqml-do-not-clear-objects-propertycaches-on-last-gc-run.patch
## upstreamable patches
@@ -736,6 +737,9 @@ make check -k -C tests ||:
%endif
%changelog
+* Thu Feb 19 2026 Jan Grulich <jgrulich@redhat.com> - 6.10.2-2
+- QtQml: Do not clear objects propertyCaches on last GC run
+
* Mon Feb 09 2026 Jan Grulich <jgrulich@redhat.com> - 6.10.2-1
- 6.10.2
diff --git a/qtdeclarative-qtqml-do-not-clear-objects-propertycaches-on-last-gc-run.patch b/qtdeclarative-qtqml-do-not-clear-objects-propertycaches-on-last-gc-run.patch
new file mode 100644
index 0000000..9ce08be
--- /dev/null
+++ b/qtdeclarative-qtqml-do-not-clear-objects-propertycaches-on-last-gc-run.patch
@@ -0,0 +1,133 @@
+From dc2358e98b8ddab532866a403ffc09d1162ad0f9 Mon Sep 17 00:00:00 2001
+From: Ulf Hermann <ulf.hermann@qt.io>
+Date: Tue, 13 Jan 2026 11:53:27 +0100
+Subject: [PATCH] QtQml: Do not clear objects' propertyCaches on last GC run
+
+The property caches are not specific to the engine. The same object may
+be exposed to other engines and still require its property cache. When
+the clearing of the property caches on engine destruction was
+introduced, the property caches were still engine-specific and we had no
+choice but to clear them. Otherwise any further access would lead to a
+dereference of a dangling pointer.
+
+Furthermore, when clearing the JS wrapper for a QObject, check if it's
+actually the wrapper being deleted. We don't want to clear some other
+engine's wrapper.
+
+Amends commit 749a7212e903d8e8c6f256edb1836b9449cc7fe1.
+Amends commit c6b2dd879d02b21b18f80faab541f8f04286685a.
+
+Pick-to: 6.11 6.10
+Fixes: QTBUG-142514
+Change-Id: I40bb1aeca65225d56cb1d2ff498f5f1722216a70
+Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
+---
+
+diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
+index a8dfd50..e61867b 100644
+--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
++++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
+@@ -1583,10 +1583,9 @@
+ o->deleteLater();
+ } else {
+ // If the object is C++-owned, we still have to release the weak reference we have
+- // to it.
+- ddata->jsWrapper.clear();
+- if (lastCall && ddata->propertyCache)
+- ddata->propertyCache.reset();
++ // to it. If the "main" wrapper is not ours, we should leave it alone, though.
++ if (ddata->jsWrapper.as<QObjectWrapper>() == this)
++ ddata->jsWrapper.clear();
+ }
+ }
+ }
+diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+index b56b241..11bc62e 100644
+--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
++++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+@@ -1119,7 +1119,7 @@
+ engine.newQObject(obj.data());
+ QVERIFY(QQmlData::get(obj.data())->propertyCache);
+ }
+- QVERIFY(!QQmlData::get(obj.data())->propertyCache);
++ QVERIFY(QQmlData::get(obj.data())->propertyCache);
+ }
+
+ void tst_QJSEngine::newQMetaObject() {
+diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+index 88cc102..8949d00 100644
+--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
++++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+@@ -326,6 +326,7 @@
+ stringLength.qml
+ stringToByteArray.qml
+ structuredValueType.qml
++ multiEnginePropertyCache.qml
+ takenumber.qml
+ testlogger.js
+ text.qml
+diff --git a/tests/auto/qml/qmlcppcodegen/data/multiEnginePropertyCache.qml b/tests/auto/qml/qmlcppcodegen/data/multiEnginePropertyCache.qml
+new file mode 100644
+index 0000000..222b2f8
+--- /dev/null
++++ b/tests/auto/qml/qmlcppcodegen/data/multiEnginePropertyCache.qml
+@@ -0,0 +1,20 @@
++pragma Strict
++import QtQml
++
++QtObject {
++ id: root
++
++ property int foo: 0
++ onFooChanged: root.close1()
++
++ property int bar: 0
++ onBarChanged: close2()
++
++ function close1() {
++ console.log("close1")
++ }
++
++ function close2() {
++ console.log("close2")
++ }
++}
+diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+index 3ce5627..8d98c02 100644
+--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
++++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+@@ -280,6 +280,7 @@
+ void stringLength();
+ void stringToByteArray();
+ void structuredValueType();
++ void multiEnginePropertyCache();
+ void takeNumbers();
+ void takeNumbers_data();
+ void testIsnan();
+@@ -5795,6 +5796,26 @@
+ QCOMPARE(o->property("w2").value<WeatherModelUrl>(), w2);
+ }
+
++void tst_QmlCppCodegen::multiEnginePropertyCache()
++{
++ QQmlEngine engine;
++ QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/multiEnginePropertyCache.qml"_s));
++ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
++ std::unique_ptr<QObject> o(c.create());
++ QVERIFY(o);
++
++ {
++ QJSEngine other;
++ other.newQObject(o.get());
++ }
++
++ QTest::ignoreMessage(QtDebugMsg, "close1");
++ o->setProperty("foo", 1);
++
++ QTest::ignoreMessage(QtDebugMsg, "close2");
++ o->setProperty("bar", 2);
++}
++
+ void tst_QmlCppCodegen::takeNumbers()
+ {
+ QFETCH(QByteArray, method);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-08 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08 17:40 [rpms/qt6-qtdeclarative] epel9: QtQml: Do not clear objects propertyCaches on last GC run Jan Grulich
2026-10-08 17:40 Jan Grulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox