aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2014-11-13 21:38:25 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-11-21 19:32:23 +0100
commit2784a68d64519ccc5d01b6c1378207572cf1ebcd (patch)
treeb66287687e7311a24253d60e18bcba829fb475ad /src/qml/qml
parent2cb6d1bf32e017026f618dcfdbef3980f5363656 (diff)
Cleanup destruction of heap objects
Generate the code from a macro instead of duplicating boiler plate code. Operate on Heap::Base instead of Managed. Change-Id: I84c5a705980899be3e5b931a093645e50d3923bf Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp7
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp5
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h2
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp6
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h2
-rw-r--r--src/qml/qml/qqmllocale_p.h7
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp5
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h6
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp11
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp20
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions_p.h5
12 files changed, 16 insertions, 62 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 33cffe6629..5b6db65a6c 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1089,6 +1089,7 @@ struct QmlIncubatorObject : Object {
struct QmlIncubatorObject : public QV4::Object
{
V4_OBJECT2(QmlIncubatorObject, Object)
+ V4_NEEDS_DESTROY
static QV4::ReturnedValue method_get_statusChanged(QV4::CallContext *ctx);
static QV4::ReturnedValue method_set_statusChanged(QV4::CallContext *ctx);
@@ -1096,7 +1097,6 @@ struct QmlIncubatorObject : public QV4::Object
static QV4::ReturnedValue method_get_object(QV4::CallContext *ctx);
static QV4::ReturnedValue method_forceCompletion(QV4::CallContext *ctx);
- static void destroy(Managed *that);
static void markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e);
void statusChanged(QQmlIncubator::Status);
@@ -1507,11 +1507,6 @@ void QV4::QmlIncubatorObject::setInitialState(QObject *o)
}
}
-void QV4::QmlIncubatorObject::destroy(Managed *that)
-{
- static_cast<QmlIncubatorObject *>(that)->d()->~Data();
-}
-
void QV4::QmlIncubatorObject::markObjects(QV4::Heap::Base *that, QV4::ExecutionEngine *e)
{
QmlIncubatorObject::Data *o = static_cast<QmlIncubatorObject::Data *>(that);
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 6e75f6e135..51e72223d0 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -342,11 +342,6 @@ void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value)
Object::put(m, name, value);
}
-void QmlContextWrapper::destroy(Managed *that)
-{
- static_cast<QmlContextWrapper *>(that)->d()->~Data();
-}
-
void QmlContextWrapper::markObjects(Heap::Base *m, ExecutionEngine *engine)
{
QmlContextWrapper::Data *This = static_cast<QmlContextWrapper::Data *>(m);
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index 317cf4ced2..37283349d4 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -88,6 +88,7 @@ struct QQmlIdObjectsArray : Object {
struct Q_QML_EXPORT QmlContextWrapper : Object
{
V4_OBJECT2(QmlContextWrapper, Object)
+ V4_NEEDS_DESTROY
static ReturnedValue qmlScope(QV8Engine *e, QQmlContextData *ctxt, QObject *scope);
static ReturnedValue urlScope(QV8Engine *e, const QUrl &);
@@ -103,7 +104,6 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const ValueRef value);
- static void destroy(Managed *that);
static void markObjects(Heap::Base *m, ExecutionEngine *engine);
static void registerQmlDependencies(ExecutionEngine *context, const CompiledData::Function *compiledFunction);
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 0076933783..6cef1d45d1 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -143,12 +143,6 @@ void QmlListWrapper::put(Managed *m, String *name, const ValueRef value)
Q_UNUSED(value);
}
-void QmlListWrapper::destroy(Managed *that)
-{
- Q_ASSERT(that->as<QmlListWrapper>());
- static_cast<QmlListWrapper *>(that)->d()->~Data();
-}
-
void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
{
name = (String *)0;
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index e73f03f99b..65d7154f77 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -75,6 +75,7 @@ struct QmlListWrapper : Object {
struct Q_QML_EXPORT QmlListWrapper : Object
{
V4_OBJECT2(QmlListWrapper, Object)
+ V4_NEEDS_DESTROY
static ReturnedValue create(QV8Engine *v8, QObject *object, int propId, int propType);
static ReturnedValue create(QV8Engine *v8, const QQmlListProperty<QObject> &prop, int propType);
@@ -85,7 +86,6 @@ struct Q_QML_EXPORT QmlListWrapper : Object
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void put(Managed *m, String *name, const ValueRef value);
static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes);
- static void destroy(Managed *that);
};
}
diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h
index 34224b44ff..744d82a6d2 100644
--- a/src/qml/qml/qqmllocale_p.h
+++ b/src/qml/qml/qqmllocale_p.h
@@ -135,6 +135,7 @@ struct QQmlLocaleData : Object {
struct QQmlLocaleData : public QV4::Object
{
V4_OBJECT2(QQmlLocaleData, Object)
+ V4_NEEDS_DESTROY
static QLocale *getThisLocale(QV4::CallContext *ctx) {
QV4::Object *o = ctx->d()->callData->thisObject.asObject();
@@ -173,12 +174,6 @@ struct QQmlLocaleData : public QV4::Object
static QV4::ReturnedValue method_get_exponential(QV4::CallContext *ctx);
static QV4::ReturnedValue method_get_amText(QV4::CallContext *ctx);
static QV4::ReturnedValue method_get_pmText(QV4::CallContext *ctx);
-
-private:
- static void destroy(Managed *that)
- {
- static_cast<QQmlLocaleData *>(that)->d()->~Data();
- }
};
Heap::QQmlLocaleData::QQmlLocaleData(ExecutionEngine *engine)
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 0a4be41ced..df3a17f968 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -281,11 +281,6 @@ PropertyAttributes QmlTypeWrapper::query(const Managed *m, String *name)
return hasProperty ? Attr_Data : Attr_Invalid;
}
-void QmlTypeWrapper::destroy(Managed *that)
-{
- static_cast<QmlTypeWrapper *>(that)->d()->~Data();
-}
-
bool QmlTypeWrapper::isEqualTo(Managed *a, Managed *b)
{
Q_ASSERT(a->as<QV4::QmlTypeWrapper>());
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index a0a119630d..aff1fc0916 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -82,9 +82,7 @@ struct QmlTypeWrapper : Object {
struct Q_QML_EXPORT QmlTypeWrapper : Object
{
V4_OBJECT2(QmlTypeWrapper, Object)
-private:
-
-public:
+ V4_NEEDS_DESTROY
bool isSingleton() const;
QObject *singletonObject() const;
@@ -100,8 +98,6 @@ public:
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const ValueRef value);
static PropertyAttributes query(const Managed *, String *name);
- static void destroy(Managed *that);
-
static bool isEqualTo(Managed *that, Managed *o);
};
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 2fe903bcc9..346e745234 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -187,14 +187,13 @@ QVariant QmlValueTypeWrapper::toVariant() const
}
}
-void QmlValueTypeWrapper::destroy(Managed *that)
+void QmlValueTypeWrapper::destroy(Heap::Base *that)
{
- Q_ASSERT(that->as<QmlValueTypeWrapper>());
- QmlValueTypeWrapper *w = static_cast<QmlValueTypeWrapper *>(that);
- if (w->d()->objectType == Heap::QmlValueTypeWrapper::Reference)
- static_cast<QmlValueTypeReference *>(w)->d()->Heap::QmlValueTypeReference::~QmlValueTypeReference();
+ Heap::QmlValueTypeWrapper *w = static_cast<Heap::QmlValueTypeWrapper *>(that);
+ if (w->objectType == Heap::QmlValueTypeWrapper::Reference)
+ static_cast<Heap::QmlValueTypeReference *>(w)->Heap::QmlValueTypeReference::~QmlValueTypeReference();
else
- static_cast<QmlValueTypeCopy *>(w)->d()->Heap::QmlValueTypeCopy::~QmlValueTypeCopy();
+ static_cast<Heap::QmlValueTypeCopy *>(w)->Heap::QmlValueTypeCopy::~QmlValueTypeCopy();
}
bool QmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other)
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index 36ab038884..d15a4b0cef 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -73,6 +73,7 @@ struct QmlValueTypeWrapper : Object {
struct Q_QML_EXPORT QmlValueTypeWrapper : Object
{
V4_OBJECT2(QmlValueTypeWrapper, Object)
+ static void destroy(Heap::Base *b);
public:
@@ -84,7 +85,6 @@ public:
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static void put(Managed *m, String *name, const ValueRef value);
- static void destroy(Managed *that);
static bool isEqualTo(Managed *m, Managed *other);
static PropertyAttributes query(const Managed *, String *name);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 0083d2353c..b84c878d53 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -216,14 +216,12 @@ class NamedNodeMap : public Object
{
public:
V4_OBJECT2(NamedNodeMap, Object)
+ V4_NEEDS_DESTROY
// C++ API
static ReturnedValue create(QV8Engine *, NodeImpl *, const QList<NodeImpl *> &);
// JS API
- static void destroy(Managed *that) {
- static_cast<NamedNodeMap *>(that)->d()->~Data();
- }
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
};
@@ -245,11 +243,9 @@ class NodeList : public Object
{
public:
V4_OBJECT2(NodeList, Object)
+ V4_NEEDS_DESTROY
// JS API
- static void destroy(Managed *that) {
- static_cast<NodeList *>(that)->d()->~Data();
- }
static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
@@ -328,12 +324,7 @@ DEFINE_OBJECT_VTABLE(NodePrototype);
struct Node : public Object
{
V4_OBJECT2(Node, Object)
-
-
- // JS API
- static void destroy(Managed *that) {
- static_cast<Node *>(that)->d()->~Data();
- }
+ V4_NEEDS_DESTROY
// C++ API
static ReturnedValue create(QV8Engine *, NodeImpl *);
@@ -1629,10 +1620,7 @@ struct QQmlXMLHttpRequestCtor : FunctionObject {
struct QQmlXMLHttpRequestWrapper : public Object
{
V4_OBJECT2(QQmlXMLHttpRequestWrapper, Object)
-
- static void destroy(Managed *that) {
- static_cast<QQmlXMLHttpRequestWrapper *>(that)->d()->~Data();
- }
+ V4_NEEDS_DESTROY
};
Heap::QQmlXMLHttpRequestWrapper::QQmlXMLHttpRequestWrapper(ExecutionEngine *engine, QQmlXMLHttpRequest *request)
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
index baedd19e47..57fd290aef 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h
@@ -159,16 +159,13 @@ struct GlobalExtensions {
struct QQmlBindingFunction : public QV4::FunctionObject
{
V4_OBJECT2(QQmlBindingFunction, FunctionObject)
+ V4_NEEDS_DESTROY
void initBindingLocation(); // from caller stack trace
static ReturnedValue call(Managed *that, CallData *callData);
static void markObjects(Heap::Base *that, ExecutionEngine *e);
- static void destroy(Managed *that) {
- static_cast<QQmlBindingFunction *>(that)->d()->~Data();
- }
-
};
}