diff options
author | Erik Verbruggen <[email protected]> | 2016-09-09 16:20:57 +0200 |
---|---|---|
committer | Simon Hausmann <[email protected]> | 2016-10-06 14:46:21 +0000 |
commit | 57c9d6969ac474177c77d5ea59768b39620a3b2f (patch) | |
tree | d7fab7663b43af13f7551e9360a588594b7d21cf /src/qml/jsruntime | |
parent | 6c05fe9cb760a9a26d7a1a8037aa62966a3bd344 (diff) |
QML: Also check for correct destroy() chaining
Check that the destroy() method of Heap::Base was called when a Managed
object needs destruction. This checks if a call to the parent's
destroy() method was accidentally omitted.
Change-Id: Id025ecd6d4744bf3eab23503fbe317ed2a461138
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4arraybuffer.cpp | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4arraydata_p.h | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4errorobject_p.h | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper_p.h | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexp.cpp | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4sequenceobject.cpp | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4variantobject_p.h | 1 |
10 files changed, 23 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 908fa52680..23075aa78c 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -118,6 +118,7 @@ void Heap::ArrayBuffer::destroy() { if (!data->ref.deref()) QTypedArrayData<char>::deallocate(data); + Object::destroy(); } QByteArray ArrayBuffer::asByteArray() const diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index 9f810a32d5..24b948f01e 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -156,7 +156,10 @@ struct SimpleArrayData : public ArrayData { V4_ASSERT_IS_TRIVIAL(SimpleArrayData) struct SparseArrayData : public ArrayData { - void destroy() { delete sparse; } + void destroy() { + delete sparse; + ArrayData::destroy(); + } uint mappedIndex(uint index) const { SparseArrayNode *n = sparse->findNode(index); diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index b7a0889e08..42a6e0b4b1 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -76,7 +76,10 @@ struct ErrorObject : Object { void init(); void init(const Value &message, ErrorType t = Error); void init(const Value &message, const QString &fileName, int line, int column, ErrorType t = Error); - void destroy() { delete stackTrace; } + void destroy() { + delete stackTrace; + Object::destroy(); + } ErrorType errorType; StackTrace *stackTrace; diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 118ed89c43..2cc58b74a6 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -147,6 +147,7 @@ void Heap::FunctionObject::destroy() { if (function) function->compilationUnit->release(); + Object::destroy(); } void FunctionObject::init(String *n, bool createProto) diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 6ddeb84d3c..e13a701b0f 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -69,6 +69,7 @@ namespace Heap { struct Object : Base { void init() { Base::init(); } + void destroy() { Base::destroy(); } const Value *propertyData(uint index) const { if (index < inlineMemberSize) return reinterpret_cast<const Value *>(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; } Value *propertyData(uint index) { if (index < inlineMemberSize) return reinterpret_cast<Value *>(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; } diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 727af6c9c6..a32244c8de 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -79,7 +79,10 @@ struct QQmlValueTypeWrapper; struct QObjectWrapper : Object { void init(QObject *object); - void destroy() { qObj.destroy(); } + void destroy() { + qObj.destroy(); + Object::destroy(); + } QObject *object() const { return qObj.data(); } @@ -131,7 +134,10 @@ struct QMetaObjectWrapper : FunctionObject { struct QmlSignalHandler : Object { void init(QObject *object, int signalIndex); - void destroy() { qObj.destroy(); } + void destroy() { + qObj.destroy(); + Object::destroy(); + } int signalIndex; QObject *object() const { return qObj.data(); } diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index c2bc905ef5..9e94c58432 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -124,6 +124,7 @@ void Heap::RegExp::destroy() #endif delete byteCode; delete pattern; + Base::destroy(); } void RegExp::markObjects(Heap::Base *that, ExecutionEngine *e) diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 4b82a7d83f..24890fdb18 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -221,6 +221,7 @@ struct QQmlSequence : Object { void destroy() { delete container; object.destroy(); + Object::destroy(); } mutable Container *container; diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index df34ec0151..23ec3349b9 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -76,6 +76,7 @@ struct Q_QML_PRIVATE_EXPORT String : Base { void destroy() { if (!largestSubLength && !text->ref.deref()) QStringData::deallocate(text); + Base::destroy(); } void simplifyString() const; int length() const { diff --git a/src/qml/jsruntime/qv4variantobject_p.h b/src/qml/jsruntime/qv4variantobject_p.h index efaf5e1e65..9a04069c12 100644 --- a/src/qml/jsruntime/qv4variantobject_p.h +++ b/src/qml/jsruntime/qv4variantobject_p.h @@ -73,6 +73,7 @@ struct VariantObject : Object if (isScarce()) addVmePropertyReference(); delete scarceData; + Object::destroy(); } bool isScarce() const; int vmePropertyReferenceCount; |