aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvmemetaobject_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-11-04 13:12:03 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-11-05 18:18:56 +0100
commit21844350df530a65071e8679d5e047adf553e0f7 (patch)
treed4aea3bb42347a01f48f3640876426f778d71053 /src/qml/qml/qqmlvmemetaobject_p.h
parent15d1b173d030f5ae5ca72f511d33c80979503268 (diff)
QQmlVMEMetaObject: Scope MemberData for allocating write
If we need to allocate in order to write a property of the object, we need to make sure that the member data is not garbage collected during that allocation. Change-Id: I885cdc547588c1b20450e1586765cd0266b4c4f0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject_p.h')
-rw-r--r--src/qml/qml/qqmlvmemetaobject_p.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject_p.h b/src/qml/qml/qqmlvmemetaobject_p.h
index dbcc9d2884..35bc35ce4b 100644
--- a/src/qml/qml/qqmlvmemetaobject_p.h
+++ b/src/qml/qml/qqmlvmemetaobject_p.h
@@ -196,12 +196,18 @@ public:
void writeProperty(int id, bool v);
void writeProperty(int id, double v);
void writeProperty(int id, const QString& v);
- void writeProperty(int id, const QPointF& v);
- void writeProperty(int id, const QSizeF& v);
- void writeProperty(int id, const QUrl& v);
- void writeProperty(int id, const QDate& v);
- void writeProperty(int id, const QDateTime& v);
- void writeProperty(int id, const QRectF& v);
+
+ template<typename VariantCompatible>
+ void writeProperty(int id, const VariantCompatible &v)
+ {
+ QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
+ if (md) {
+ QV4::Scope scope(engine);
+ QV4::Scoped<QV4::MemberData>(scope, md)->set(engine, id, engine->newVariantObject(
+ QVariant::fromValue(v)));
+ }
+ }
+
void writeProperty(int id, QObject *v);
void ensureQObjectWrapper();