aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4sequenceobject_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-10-05 17:02:03 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-10-19 20:32:01 +0200
commita824a6f060ec3a0000d7349649a3ab9e0570ecaa (patch)
tree9574d4f96d52bf0de792bab52d42bd35a08027e6 /src/qml/jsruntime/qv4sequenceobject_p.h
parente89a06753c772bd96b3299e03b2f7ad78ffc9fb9 (diff)
Recursively write back value types and sequences
Both types have functionality to write themselves back to the properties they were loaded from on change, but so far we could not nest those writes. [ChangeLog][QtQml] You can now assign to properties of nested value types and to elements of containers from QML functions. You cannot, however, take references of such values and elements. This is in contrast to non-nested value types and the containers themselves. However, passing references of value types and containers around generally leads to very confusing effects. Don't do this. Fixes: QTBUG-99766 Change-Id: I74cb89e5c3d733b0b61e42969d617b2ecc1562f4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4sequenceobject_p.h')
-rw-r--r--src/qml/jsruntime/qv4sequenceobject_p.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4sequenceobject_p.h b/src/qml/jsruntime/qv4sequenceobject_p.h
index f6055e38e3..282928e661 100644
--- a/src/qml/jsruntime/qv4sequenceobject_p.h
+++ b/src/qml/jsruntime/qv4sequenceobject_p.h
@@ -36,7 +36,9 @@ struct Q_QML_PRIVATE_EXPORT SequencePrototype : public QV4::Object
static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
- static ReturnedValue newSequence(QV4::ExecutionEngine *engine, QMetaType sequenceType, QObject *object, int propertyIndex, bool readOnly);
+ static ReturnedValue newSequence(
+ QV4::ExecutionEngine *engine, QMetaType sequenceType, const void *data,
+ Heap::Object *object, int propertyIndex, Heap::ReferenceObject::Flags flags);
static ReturnedValue fromVariant(QV4::ExecutionEngine *engine, const QVariant &vd);
static ReturnedValue fromData(QV4::ExecutionEngine *engine, QMetaType type, const void *data);
@@ -51,22 +53,26 @@ namespace Heap {
struct Sequence : ReferenceObject
{
void init(const QQmlType &qmlType, const void *container);
- void init(QObject *object, int propertyIndex, const QQmlType &qmlType, bool readOnly);
+ void init(const QQmlType &qmlType, const void *container,
+ Object *object, int propertyIndex, Heap::ReferenceObject::Flags flags);
+
+ Sequence *detached() const;
void destroy();
- void *storagePointer() { return m_container; }
+ bool hasData() const { return m_container != nullptr; }
+ void *storagePointer();
const void *storagePointer() const { return m_container; }
+ bool isReadOnly() const { return m_object && !canWriteBack(); }
+
bool setVariant(const QVariant &variant);
QVariant toVariant() const;
const QQmlTypePrivate *typePrivate() const { return m_typePrivate; }
- bool isReadOnly() const { return m_isReadOnly; }
private:
void *m_container;
const QQmlTypePrivate *m_typePrivate;
- bool m_isReadOnly;
};
}
@@ -85,6 +91,7 @@ public:
static bool virtualDeleteProperty(QV4::Managed *that, PropertyKey id);
static bool virtualIsEqualTo(Managed *that, Managed *other);
static QV4::OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
+ static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a);
qsizetype size() const;
QVariant at(qsizetype index) const;
@@ -92,7 +99,6 @@ public:
void append(qsizetype num, const QVariant &item);
void replace(qsizetype index, const QVariant &item);
void removeLast(qsizetype num);
- QVariant toVariant() const;
QV4::ReturnedValue containerGetIndexed(qsizetype index, bool *hasProperty) const;
bool containerPutIndexed(qsizetype index, const QV4::Value &value);