diff options
Diffstat (limited to 'src/qml/jsruntime/qv4qobjectwrapper_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper_p.h | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 076f304fea..8b2fd506e8 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -77,9 +77,12 @@ namespace Heap { struct QQmlValueTypeWrapper; -struct QObjectWrapper : Object { - QObjectWrapper(QObject *object); - ~QObjectWrapper() { qObj.destroy(); } +struct Q_QML_EXPORT QObjectWrapper : Object { + void init(QObject *object); + void destroy() { + qObj.destroy(); + Object::destroy(); + } QObject *object() const { return qObj.data(); } @@ -88,10 +91,22 @@ private: }; struct QObjectMethod : FunctionObject { - QObjectMethod(QV4::ExecutionContext *scope); - ~QObjectMethod() { qObj.destroy(); } - QQmlRefPointer<QQmlPropertyCache> propertyCache; - int index; + void init(QV4::ExecutionContext *scope); + void destroy() + { + setPropertyCache(nullptr); + qObj.destroy(); + FunctionObject::destroy(); + } + + QQmlPropertyCache *propertyCache() const { return _propertyCache; } + void setPropertyCache(QQmlPropertyCache *c) { + if (c) + c->addref(); + if (_propertyCache) + _propertyCache->release(); + _propertyCache = c; + } Pointer<QQmlValueTypeWrapper> valueTypeWrapper; @@ -101,6 +116,10 @@ struct QObjectMethod : FunctionObject { private: QQmlQPointer<QObject> qObj; + QQmlPropertyCache *_propertyCache; + +public: + int index; }; struct QMetaObjectWrapper : FunctionObject { @@ -108,14 +127,17 @@ struct QMetaObjectWrapper : FunctionObject { QQmlPropertyData *constructors; int constructorCount; - QMetaObjectWrapper(const QMetaObject* metaObject); - ~QMetaObjectWrapper(); + void init(const QMetaObject* metaObject); + void destroy(); void ensureConstructorsCache(); }; struct QmlSignalHandler : Object { - QmlSignalHandler(QObject *object, int signalIndex); - ~QmlSignalHandler() { qObj.destroy(); } + void init(QObject *object, int signalIndex); + void destroy() { + qObj.destroy(); + Object::destroy(); + } int signalIndex; QObject *object() const { return qObj.data(); } @@ -130,6 +152,7 @@ private: struct Q_QML_EXPORT QObjectWrapper : public Object { V4_OBJECT2(QObjectWrapper, Object) + V4_NEEDS_DESTROY enum RevisionMode { IgnoreRevision, CheckRevision }; |