diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmllistwrapper.cpp | 18 | ||||
-rw-r--r-- | src/qml/qml/qqmllistwrapper_p.h | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index 244b77f76f..eadd95fce8 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -27,11 +27,22 @@ static void setCustomArrayData(Heap::QmlListWrapper *d) o->setArrayType(Heap::ArrayData::Custom); } +void Heap::QmlListWrapper::init(QMetaType propertyType) +{ + Object::init(); + m_object.init(); + m_propertyType = propertyType.iface(); + m_ownData = new QObjectList; + *property() = QQmlListProperty<QObject>(nullptr, m_ownData); + setCustomArrayData(this); +} + void Heap::QmlListWrapper::init(QObject *object, int propertyId, QMetaType propertyType) { Object::init(); m_object.init(object); m_propertyType = propertyType.iface(); + m_ownData = nullptr; void *args[] = { property(), nullptr }; QMetaObject::metacall(object, QMetaObject::ReadProperty, propertyId, args); setCustomArrayData(this); @@ -43,6 +54,7 @@ void Heap::QmlListWrapper::init( Object::init(); m_object.init(object); m_propertyType = propertyType.iface(); + m_ownData = nullptr; *property() = list; setCustomArrayData(this); } @@ -50,6 +62,7 @@ void Heap::QmlListWrapper::init( void Heap::QmlListWrapper::destroy() { m_object.destroy(); + delete m_ownData; Object::destroy(); } @@ -69,6 +82,11 @@ ReturnedValue QmlListWrapper::create( ->asReturnedValue(); } +ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, QMetaType propType) +{ + return engine->memoryManager->allocate<QmlListWrapper>(propType)->asReturnedValue(); +} + QVariant QmlListWrapper::toVariant() const { if (!d()->object()) diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h index ecd3ef7fbe..55c965e13a 100644 --- a/src/qml/qml/qqmllistwrapper_p.h +++ b/src/qml/qml/qqmllistwrapper_p.h @@ -30,6 +30,7 @@ namespace QV4 { namespace Heap { struct QmlListWrapper : Object { + void init(QMetaType propertyType); void init(QObject *object, int propertyId, QMetaType propertyType); void init(QObject *object, const QQmlListProperty<QObject> &list, QMetaType propertyType); void destroy(); @@ -54,6 +55,8 @@ private: // interface instead of QMetaType to keep class a POD const QtPrivate::QMetaTypeInterface *m_propertyType; + + QObjectList *m_ownData; }; } @@ -67,6 +70,7 @@ struct Q_QML_EXPORT QmlListWrapper : Object static ReturnedValue create(ExecutionEngine *engine, QObject *object, int propId, QMetaType propType); static ReturnedValue create(ExecutionEngine *engine, const QQmlListProperty<QObject> &prop, QMetaType propType); + static ReturnedValue create(ExecutionEngine *engine, QMetaType propType); QVariant toVariant() const; QQmlListReference toListReference() const; |