diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2016-09-09 16:20:57 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-10-06 14:46:21 +0000 |
commit | 57c9d6969ac474177c77d5ea59768b39620a3b2f (patch) | |
tree | d7fab7663b43af13f7551e9360a588594b7d21cf /src/qml/qml | |
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 <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontextwrapper.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmllistwrapper.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmllocale_p.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmltypewrapper.cpp | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 14 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 1 |
8 files changed, 19 insertions, 9 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 23b8e5a712..8be5172cd4 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1497,6 +1497,7 @@ void QV4::Heap::QmlIncubatorObject::init(QQmlIncubator::IncubationMode m) void QV4::Heap::QmlIncubatorObject::destroy() { delete incubator; parent.destroy(); + Object::destroy(); } void QV4::QmlIncubatorObject::setInitialState(QObject *o) diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 8827216136..2418003519 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -77,6 +77,7 @@ void Heap::QmlContextWrapper::destroy() (*context)->destroy(); delete context; scopeObject.destroy(); + Object::destroy(); } ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope) diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index 91225a1fea..8aa107dc17 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -64,6 +64,7 @@ void Heap::QmlListWrapper::init() void Heap::QmlListWrapper::destroy() { object.destroy(); + Object::destroy(); } ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, QObject *object, int propId, int propType) diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index ea1b7bf369..275f58db7d 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -144,7 +144,10 @@ namespace Heap { struct QQmlLocaleData : Object { inline void init() { locale = new QLocale; } - void destroy() { delete locale; } + void destroy() { + delete locale; + Object::destroy(); + } QLocale *locale; }; diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index a3ac207fc3..5c3ad6b2a6 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -67,6 +67,7 @@ void Heap::QmlTypeWrapper::destroy() if (typeNamespace) typeNamespace->release(); object.destroy(); + Object::destroy(); } bool QmlTypeWrapper::isSingleton() const diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 11849d2c63..b23bc033d1 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -67,7 +67,10 @@ struct QQmlValueTypeReference : QQmlValueTypeWrapper QQmlValueTypeWrapper::init(); object.init(); } - void destroy() { object.destroy(); } + void destroy() { + object.destroy(); + QQmlValueTypeWrapper::destroy(); + } QQmlQPointer<QObject> object; int property; }; @@ -77,8 +80,7 @@ struct QQmlValueTypeReference : QQmlValueTypeWrapper struct QQmlValueTypeReference : public QQmlValueTypeWrapper { V4_OBJECT2(QQmlValueTypeReference, QQmlValueTypeWrapper) - - static void destroy(Heap::Base *that); + V4_NEEDS_DESTROY bool readReferenceValue() const; }; @@ -95,6 +97,7 @@ void Heap::QQmlValueTypeWrapper::destroy() valueType->metaType.destruct(gadgetPtr); ::operator delete(gadgetPtr); } + Object::destroy(); } void Heap::QQmlValueTypeWrapper::setValue(const QVariant &value) const @@ -491,9 +494,4 @@ void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) } } -void QQmlValueTypeReference::destroy(Heap::Base *that) -{ - static_cast<Heap::QQmlValueTypeReference*>(that)->Heap::QQmlValueTypeReference::~QQmlValueTypeReference(); -} - QT_END_NAMESPACE diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index fe2d7da694..f94946820f 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -179,6 +179,7 @@ struct NamedNodeMap : Object { delete listPtr; if (d) d->release(); + Object::destroy(); } QList<NodeImpl *> &list() { if (listPtr == nullptr) @@ -195,6 +196,7 @@ struct NodeList : Object { void destroy() { if (d) d->release(); + Object::destroy(); } NodeImpl *d; }; @@ -208,6 +210,7 @@ struct Node : Object { void destroy() { if (d) d->release(); + Object::destroy(); } NodeImpl *d; }; @@ -1605,6 +1608,7 @@ struct QQmlXMLHttpRequestWrapper : Object { void destroy() { delete request; + Object::destroy(); } QQmlXMLHttpRequest *request; }; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index c4bb5504a3..7602a92582 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -84,6 +84,7 @@ struct QQmlBindingFunction : FunctionObject { void init(const QV4::FunctionObject *originalFunction); void destroy() { delete bindingLocation; + Object::destroy(); } Pointer<FunctionObject> originalFunction; // Set when the binding is created later |