diff options
34 files changed, 59 insertions, 156 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 93c1283ea6..9e94cd8bd8 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -116,6 +116,7 @@ class QQmlSqlDatabaseWrapper : public Object { public: V4_OBJECT2(QQmlSqlDatabaseWrapper, Object) + V4_NEEDS_DESTROY static Heap::QQmlSqlDatabaseWrapper *create(QV8Engine *engine) { @@ -127,9 +128,6 @@ public: } static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void destroy(Managed *that) { - static_cast<QQmlSqlDatabaseWrapper *>(that)->~QQmlSqlDatabaseWrapper(); - } }; } diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index a74e5c6299..b8b9971635 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -96,6 +96,12 @@ Heap::ArrayBuffer::ArrayBuffer(ExecutionEngine *e, int length) memset(data->data(), 0, length + 1); } +Heap::ArrayBuffer::~ArrayBuffer() +{ + if (!data->ref.deref()) + QTypedArrayData<char>::deallocate(data); +} + QByteArray ArrayBuffer::asByteArray() const { QByteArrayDataPtr ba = { d()->data }; @@ -103,14 +109,6 @@ QByteArray ArrayBuffer::asByteArray() const return QByteArray(ba); } -void ArrayBuffer::destroy(Managed *m) -{ - ArrayBuffer *b = static_cast<ArrayBuffer *>(m); - if (!b->d()->data->ref.deref()) - QTypedArrayData<char>::deallocate(b->d()->data); -} - - void ArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor) { Scope scope(engine); diff --git a/src/qml/jsruntime/qv4arraybuffer_p.h b/src/qml/jsruntime/qv4arraybuffer_p.h index e99ad8fe09..b2d24f76bc 100644 --- a/src/qml/jsruntime/qv4arraybuffer_p.h +++ b/src/qml/jsruntime/qv4arraybuffer_p.h @@ -48,6 +48,7 @@ struct ArrayBufferCtor : FunctionObject { struct ArrayBuffer : Object { ArrayBuffer(ExecutionEngine *e, int length); + ~ArrayBuffer(); QTypedArrayData<char> *data; uint byteLength() const { return data->size; } @@ -69,6 +70,7 @@ struct ArrayBufferCtor: FunctionObject struct ArrayBuffer : Object { V4_OBJECT2(ArrayBuffer, Object) + V4_NEEDS_DESTROY QByteArray asByteArray() const; uint byteLength() const { return d()->byteLength(); } @@ -81,7 +83,6 @@ struct ArrayBuffer : Object return d()->data->data(); } - static void destroy(Managed *m); }; struct ArrayBufferPrototype: Object diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index e4a8772cb6..26dce28470 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -357,12 +357,6 @@ void SparseArrayData::free(ArrayData *d, uint idx) } -void SparseArrayData::destroy(Managed *d) -{ - SparseArrayData *dd = static_cast<SparseArrayData *>(d); - delete dd->sparse(); -} - void SparseArrayData::markObjects(Heap::Base *d, ExecutionEngine *e) { Heap::SparseArrayData *dd = static_cast<Heap::SparseArrayData *>(d); diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index df6c3de8cb..1b0589ed95 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -106,6 +106,7 @@ struct SimpleArrayData : public ArrayData { struct SparseArrayData : public ArrayData { inline SparseArrayData(ExecutionEngine *engine); + inline ~SparseArrayData(); }; } @@ -196,6 +197,7 @@ struct Q_QML_EXPORT SimpleArrayData : public ArrayData struct Q_QML_EXPORT SparseArrayData : public ArrayData { V4_ARRAYDATA(SparseArrayData) + V4_NEEDS_DESTROY uint &freeList() { return d()->freeList; } uint freeList() const { return d()->freeList; } @@ -219,7 +221,6 @@ struct Q_QML_EXPORT SparseArrayData : public ArrayData return n->value; } - static void destroy(Managed *d); static void markObjects(Heap::Base *d, ExecutionEngine *e); static ArrayData *reallocate(Object *o, uint n, bool enforceAttributes); @@ -241,6 +242,12 @@ inline SparseArrayData::SparseArrayData(ExecutionEngine *engine) { setVTable(QV4::SparseArrayData::staticVTable()); } + +inline SparseArrayData::~SparseArrayData() +{ + delete sparse; +} + } inline Property *ArrayData::getProperty(uint index) diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index 2585c3e639..589d466429 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -130,12 +130,12 @@ struct ErrorObject: Object { V4_OBJECT2(ErrorObject, Object) Q_MANAGED_TYPE(ErrorObject) + V4_NEEDS_DESTROY SyntaxErrorObject *asSyntaxError(); static ReturnedValue method_get_stack(CallContext *ctx); static void markObjects(Heap::Base *that, ExecutionEngine *e); - static void destroy(Managed *that) { static_cast<ErrorObject *>(that)->d()->~Data(); } }; template<> diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 6a629f6a49..1621e52b4f 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -115,6 +115,7 @@ struct Q_QML_EXPORT FunctionObject: Object { }; V4_OBJECT2(FunctionObject, Object) Q_MANAGED_TYPE(FunctionObject) + V4_NEEDS_DESTROY Heap::ExecutionContext *scope() { return d()->scope; } Function *function() { return d()->function; } @@ -131,9 +132,6 @@ struct Q_QML_EXPORT FunctionObject: Object { using Object::call; static ReturnedValue construct(Managed *that, CallData *); static ReturnedValue call(Managed *that, CallData *d); - static void destroy(Managed *m) { - static_cast<FunctionObject *>(m)->d()->~Data(); - } static FunctionObject *cast(const Value &v) { return v.asFunctionObject(); diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index ab7580f106..8ba6597d0f 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -57,6 +57,9 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {} #define V4_MANAGED_SIZE_TEST #endif +#define V4_NEEDS_DESTROY static void destroy(QV4::Heap::Base *b) { static_cast<Data *>(b)->~Data(); } + + #define V4_MANAGED(DataClass, superClass) \ public: \ Q_MANAGED_CHECK \ @@ -117,7 +120,7 @@ struct ManagedVTable uint unused : 18; uint type : 8; const char *className; - void (*destroy)(Managed *); + void (*destroy)(Heap::Base *); void (*markObjects)(Heap::Base *, ExecutionEngine *e); bool (*isEqualTo)(Managed *m, Managed *other); }; @@ -310,7 +313,7 @@ public: bool inUse() const { return d()->inUse; } bool markBit() const { return d()->markBit; } - static void destroy(Managed *) {} + static void destroy(Heap::Base *) {} private: friend class MemoryManager; friend struct Identifiers; diff --git a/src/qml/jsruntime/qv4mm.cpp b/src/qml/jsruntime/qv4mm.cpp index cfaa6044f5..d8e3f3d468 100644 --- a/src/qml/jsruntime/qv4mm.cpp +++ b/src/qml/jsruntime/qv4mm.cpp @@ -377,7 +377,7 @@ void MemoryManager::sweep(bool lastSweep) continue; } if (m->internalClass()->vtable->destroy) - m->internalClass()->vtable->destroy(m); + m->internalClass()->vtable->destroy(m->d()); *last = i->next; free(Q_V4_PROFILE_DEALLOC(m_d->engine, i, i->size + sizeof(Data::LargeItem), @@ -419,7 +419,7 @@ void MemoryManager::sweep(char *chunkStart, std::size_t chunkSize, size_t size) VALGRIND_ENABLE_ERROR_REPORTING; #endif if (m->internalClass()->vtable->destroy) - m->internalClass()->vtable->destroy(m); + m->internalClass()->vtable->destroy(m->d()); memset(m, 0, size); m->setNextFree(*f); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index d96595af21..4a671f3219 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1034,12 +1034,12 @@ namespace { }; } -void QObjectWrapper::destroy(Managed *that) +void QObjectWrapper::destroy(Heap::Base *that) { - QObjectWrapper *This = static_cast<QObjectWrapper*>(that); - QPointer<QObject> object = This->d()->object; - ExecutionEngine *engine = This->engine(); - This->d()->~Data(); + Heap::QObjectWrapper *This = static_cast<Heap::QObjectWrapper*>(that); + QPointer<QObject> object = This->object; + ExecutionEngine *engine = This->internalClass->engine; + This->~Data(); This = 0; if (!object) return; diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index f30a98ef43..7f271a8680 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -127,7 +127,7 @@ private: static PropertyAttributes query(const Managed *, String *name); static void advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attributes); static void markObjects(Heap::Base *that, QV4::ExecutionEngine *e); - static void destroy(Managed *that); + static void destroy(Heap::Base *that); static ReturnedValue method_connect(CallContext *ctx); static ReturnedValue method_disconnect(CallContext *ctx); @@ -136,6 +136,7 @@ private: struct Q_QML_EXPORT QObjectMethod : public QV4::FunctionObject { V4_OBJECT2(QObjectMethod, QV4::FunctionObject) + V4_NEEDS_DESTROY enum { DestroyMethod = -1, ToStringMethod = -2 }; @@ -152,26 +153,15 @@ struct Q_QML_EXPORT QObjectMethod : public QV4::FunctionObject ReturnedValue callInternal(CallData *callData); static void markObjects(Heap::Base *that, QV4::ExecutionEngine *e); - static void destroy(Managed *that) - { - static_cast<QObjectMethod *>(that)->d()->~Data(); - } }; struct QmlSignalHandler : public QV4::Object { V4_OBJECT2(QmlSignalHandler, QV4::Object) - + V4_NEEDS_DESTROY int signalIndex() const { return d()->signalIndex; } QObject *object() const { return d()->object.data(); } - -private: - - static void destroy(Managed *that) - { - static_cast<QmlSignalHandler *>(that)->d()->~Data(); - } }; class MultiplyWrappedQObjectMap : public QObject, diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index 631003cbe1..349a0b21b0 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -114,11 +114,6 @@ Heap::RegExp::~RegExp() } } -void RegExp::destroy(Managed *that) -{ - static_cast<RegExp*>(that)->d()->~Data(); -} - void RegExp::markObjects(Heap::Base *that, ExecutionEngine *e) { Q_UNUSED(that); diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h index a91d1331c8..3219d56da7 100644 --- a/src/qml/jsruntime/qv4regexp_p.h +++ b/src/qml/jsruntime/qv4regexp_p.h @@ -80,6 +80,7 @@ struct RegExp : public Managed { V4_MANAGED(RegExp, Managed) Q_MANAGED_TYPE(RegExp) + V4_NEEDS_DESTROY QString pattern() const { return d()->pattern; } OwnPtr<JSC::Yarr::BytecodePattern> &byteCode() { return d()->byteCode; } @@ -99,7 +100,6 @@ struct RegExp : public Managed int captureCount() const { return subPatternCount() + 1; } - static void destroy(Managed *that); static void markObjects(Heap::Base *that, QV4::ExecutionEngine *e); friend class RegExpCache; diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 8ae4b0e0d8..a838b23d9d 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -67,12 +67,7 @@ struct CompilationUnitHolder : Object { struct CompilationUnitHolder : public Object { V4_OBJECT2(CompilationUnitHolder, Object) - - static void destroy(Managed *that) - { - static_cast<CompilationUnitHolder*>(that)->d()->~Data(); - } - + V4_NEEDS_DESTROY }; inline diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index a2de296e88..738de8b03d 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -179,6 +179,7 @@ struct QQmlSequence : public QV4::Object { V4_OBJECT2(QQmlSequence<Container>, QV4::Object) Q_MANAGED_TYPE(QmlSequence) + V4_NEEDS_DESTROY public: void init() @@ -494,10 +495,6 @@ public: static void advanceIterator(Managed *that, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs) { return static_cast<QQmlSequence<Container> *>(that)->containerAdvanceIterator(it, name, index, p, attrs); } - static void destroy(Managed *that) - { - static_cast<QQmlSequence<Container> *>(that)->d()->~Data(); - } }; diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index a06a36d7fd..5c020ddc8e 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -117,11 +117,6 @@ const ObjectVTable String::static_vtbl = 0 /*advanceIterator*/, }; -void String::destroy(Managed *that) -{ - static_cast<String*>(that)->d()->~Data(); -} - void String::markObjects(Heap::Base *that, ExecutionEngine *e) { String::Data *s = static_cast<String::Data *>(that); diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 989398883e..86b8f2bdd5 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -119,6 +119,7 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed { // ### FIXME: Should this be a V4_OBJECT V4_OBJECT2(String, Managed) Q_MANAGED_TYPE(String) + V4_NEEDS_DESTROY enum { IsString = true }; @@ -170,7 +171,6 @@ struct Q_QML_PRIVATE_EXPORT String : public Managed { Identifier *identifier() const { return d()->identifier; } protected: - static void destroy(Managed *); static void markObjects(Heap::Base *that, ExecutionEngine *e); static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp index 1a76839e59..fe23b8aa15 100644 --- a/src/qml/jsruntime/qv4variantobject.cpp +++ b/src/qml/jsruntime/qv4variantobject.cpp @@ -84,12 +84,6 @@ bool VariantObject::Data::isScarce() const return t == QVariant::Pixmap || t == QVariant::Image; } -void VariantObject::destroy(Managed *that) -{ - VariantObject *v = static_cast<VariantObject *>(that); - v->d()->~Data(); -} - bool VariantObject::isEqualTo(Managed *m, Managed *other) { Q_ASSERT(m->as<QV4::VariantObject>()); diff --git a/src/qml/jsruntime/qv4variantobject_p.h b/src/qml/jsruntime/qv4variantobject_p.h index 5d68de1be3..c231db44a6 100644 --- a/src/qml/jsruntime/qv4variantobject_p.h +++ b/src/qml/jsruntime/qv4variantobject_p.h @@ -75,13 +75,13 @@ struct VariantObject : Object, public ExecutionEngine::ScarceResourceData struct VariantObject : Object { V4_OBJECT2(VariantObject, Object) + V4_NEEDS_DESTROY static QVariant toVariant(const ValueRef v); void addVmePropertyReference(); void removeVmePropertyReference(); - static void destroy(Managed *that); static bool isEqualTo(Managed *m, Managed *other); }; 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(); - } - }; } diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index ac85f6b2d6..fcbf474008 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1888,12 +1888,6 @@ QV4::Heap::QQmlDelegateModelItemObject::~QQmlDelegateModelItemObject() item->Dispose(); } -void QQmlDelegateModelItemObject::destroy(Managed *that) -{ - static_cast<QQmlDelegateModelItemObject *>(that)->d()->~Data(); -} - - QQmlDelegateModelItem::QQmlDelegateModelItem( QQmlDelegateModelItemMetaType *metaType, int modelIndex) @@ -3276,6 +3270,7 @@ DEFINE_OBJECT_VTABLE(QQmlDelegateModelGroupChange); struct QQmlDelegateModelGroupChangeArray : public QV4::Object { V4_OBJECT2(QQmlDelegateModelGroupChangeArray, QV4::Object) + V4_NEEDS_DESTROY public: static QV4::Heap::QQmlDelegateModelGroupChangeArray *create(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes) { @@ -3323,10 +3318,6 @@ public: return Object::get(m, name, hasProperty); } - static void destroy(Managed *that) { - static_cast<QQmlDelegateModelGroupChangeArray *>(that)->d()->~Data(); - } - }; QV4::Heap::QQmlDelegateModelGroupChangeArray::QQmlDelegateModelGroupChangeArray(QV4::ExecutionEngine *engine, const QVector<QQmlChangeSet::Change> &changes) diff --git a/src/qml/types/qqmldelegatemodel_p_p.h b/src/qml/types/qqmldelegatemodel_p_p.h index 191eabb543..8635795820 100644 --- a/src/qml/types/qqmldelegatemodel_p_p.h +++ b/src/qml/types/qqmldelegatemodel_p_p.h @@ -165,8 +165,7 @@ struct QQmlDelegateModelItemObject : Object { struct QQmlDelegateModelItemObject : QV4::Object { V4_OBJECT2(QQmlDelegateModelItemObject, QV4::Object) - - static void destroy(Managed *that); + V4_NEEDS_DESTROY }; QV4::Heap::QQmlDelegateModelItemObject::QQmlDelegateModelItemObject(QV4::ExecutionEngine *engine, QQmlDelegateModelItem *item) diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 99e3d09127..9e1d3b345c 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -673,13 +673,9 @@ DEFINE_OBJECT_VTABLE(QQuickJSContext2DPrototype); struct QQuickContext2DStyle : public QV4::Object { V4_OBJECT2(QQuickContext2DStyle, QV4::Object) + V4_NEEDS_DESTROY static QV4::ReturnedValue gradient_proto_addColorStop(QV4::CallContext *ctx); -protected: - static void destroy(Managed *that) - { - static_cast<QQuickContext2DStyle *>(that)->d()->~Data(); - } }; QV4::Heap::QQuickContext2DStyle::QQuickContext2DStyle(QV4::ExecutionEngine *e) @@ -890,10 +886,8 @@ static QString qt_composite_mode_to_string(QPainter::CompositionMode op) struct QQuickJSContext2DPixelData : public QV4::Object { V4_OBJECT2(QQuickJSContext2DPixelData, QV4::Object) + V4_NEEDS_DESTROY - static void destroy(QV4::Managed *that) { - static_cast<QQuickJSContext2DPixelData *>(that)->d()->~Data(); - } static QV4::ReturnedValue getIndexed(QV4::Managed *m, uint index, bool *hasProperty); static void putIndexed(QV4::Managed *m, uint index, const QV4::ValueRef value); |