From 4632c0bfff911fa84f00aab9721519427cfa9921 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 8 May 2014 21:45:11 +0200 Subject: Convert context and list wrapper Change-Id: Ida3ac10092e1fae53f57e2e664f58c6138a17a99 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcontextwrapper.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/qml/qml/qqmlcontextwrapper.cpp') diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index f94d70f61a..53353f6f1a 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -61,22 +61,21 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(QmlContextWrapper); -QmlContextWrapper::QmlContextWrapper(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext) - : Object(QV8Engine::getV4(engine)) +QmlContextWrapper::Data::Data(QV8Engine *engine, QQmlContextData *context, QObject *scopeObject, bool ownsContext) + : Object::Data(QV8Engine::getV4(engine)) + , readOnly(true) + , ownsContext(ownsContext) + , isNullWrapper(false) + , context(context) + , scopeObject(scopeObject) { setVTable(staticVTable()); - - d()->readOnly = true; - d()->ownsContext = ownsContext; - d()->isNullWrapper = false; - d()->context = context; - d()->scopeObject = scopeObject; } -QmlContextWrapper::~QmlContextWrapper() +QmlContextWrapper::Data::~Data() { - if (d()->context && d()->ownsContext) - d()->context->destroy(); + if (context && ownsContext) + context->destroy(); } ReturnedValue QmlContextWrapper::qmlScope(QV8Engine *v8, QQmlContextData *ctxt, QObject *scope) @@ -84,7 +83,7 @@ ReturnedValue QmlContextWrapper::qmlScope(QV8Engine *v8, QQmlContextData *ctxt, ExecutionEngine *v4 = QV8Engine::getV4(v8); Scope valueScope(v4); - Scoped w(valueScope, new (v4->memoryManager) QmlContextWrapper(v8, ctxt, scope)); + Scoped w(valueScope, new (v4) QmlContextWrapper::Data(v8, ctxt, scope)); return w.asReturnedValue(); } @@ -98,7 +97,7 @@ ReturnedValue QmlContextWrapper::urlScope(QV8Engine *v8, const QUrl &url) context->isInternal = true; context->isJSContext = true; - Scoped w(scope, new (v4->memoryManager) QmlContextWrapper(v8, context, 0, true)); + Scoped w(scope, new (v4) QmlContextWrapper::Data(v8, context, 0, true)); w->d()->isNullWrapper = true; return w.asReturnedValue(); } @@ -357,7 +356,7 @@ void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value) void QmlContextWrapper::destroy(Managed *that) { - static_cast(that)->~QmlContextWrapper(); + static_cast(that)->d()->~Data(); } void QmlContextWrapper::markObjects(Managed *m, ExecutionEngine *engine) @@ -415,7 +414,9 @@ ReturnedValue QmlContextWrapper::idObjectsArray() { if (!d()->idObjectsWrapper) { ExecutionEngine *v4 = engine(); - d()->idObjectsWrapper = new (v4->memoryManager) QQmlIdObjectsArray(v4, this); + Scope scope(v4); + Scoped a(scope, new (v4) QQmlIdObjectsArray::Data(v4, this)); + d()->idObjectsWrapper = a.getPointer(); } return d()->idObjectsWrapper->asReturnedValue(); } @@ -443,12 +444,11 @@ ReturnedValue QmlContextWrapper::qmlSingletonWrapper(QV8Engine *v8, String *name DEFINE_OBJECT_VTABLE(QQmlIdObjectsArray); -QQmlIdObjectsArray::QQmlIdObjectsArray(ExecutionEngine *engine, QmlContextWrapper *contextWrapper) - : Object(engine) +QQmlIdObjectsArray::Data::Data(ExecutionEngine *engine, QmlContextWrapper *contextWrapper) + : Object::Data(engine) + , contextWrapper(contextWrapper) { setVTable(staticVTable()); - - d()->contextWrapper = contextWrapper; } ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasProperty) -- cgit v1.2.3