aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvmemetaobject.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2024-02-09 21:31:59 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2024-03-05 14:06:28 +0100
commitb0d753ee3a76aaf57a7dafc79f951da2013b3025 (patch)
treec24365b62497f64c73d5b145c34f9a327099b901 /src/qml/qml/qqmlvmemetaobject.cpp
parente19750538268c4d45fc6c60d2c90b17dd25c81e8 (diff)
Prepare for white allocations during gc (2/9): QQmlVMEMetaObject
The QQmlVMEMetaObject stores its propertyAndMethodStorage as a weak value. Consequently, no marking happens. The reason for using a weak value is not quite clear, but for now, assume that there was a good reason and manually mark the freshly allocated QV4::MemberData if necessary. Task-number: QTBUG-121910 Change-Id: Ie3e0fd7e036fe0805318dfc70891b28f70223851 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index 6259b6c315..4a2c1c810c 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -430,6 +430,12 @@ QQmlVMEMetaObject::QQmlVMEMetaObject(QV4::ExecutionEngine *engine,
uint size = compiledObject->nProperties + compiledObject->nFunctions;
if (size) {
QV4::Heap::MemberData *data = QV4::MemberData::allocate(engine, size);
+ // we only have a weak reference below; if the VMEMetaObject is already marked
+ // (triggered by the allocate call above)
+ // we therefore might never mark the member data; consequently, mark it now
+ QV4::WriteBarrier::markCustom(engine, [data](QV4::MarkStack *ms) {
+ data->mark(ms);
+ });
propertyAndMethodStorage.set(engine, data);
std::fill(data->values.values, data->values.values + data->values.size, QV4::Encode::undefined());
}