aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-11-10 16:06:43 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-11-12 12:13:38 +0100
commit3e84f76bbc7a3fe0a8428be3cd6340401065ad23 (patch)
tree88b336fb864b7bdaf6a74f56ad65f7850ca63317 /src/qml
parentf2532fd6112341d247bb2a35d28fa54293004ade (diff)
Store Heap objects in the qml binding wrapper
Change-Id: I7fae0710d148a2b07ec5f36a7fb96c2b645e564e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsruntime/qv4script.cpp15
-rw-r--r--src/qml/jsruntime/qv4script_p.h6
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp6
3 files changed, 15 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index e262eaa8ca..71a8284ec1 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -94,7 +94,7 @@ DEFINE_OBJECT_VTABLE(CompilationUnitHolder);
Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, Function *f, QV4::Object *qml)
: Heap::FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false)
- , qml(qml)
+ , qml(qml->d())
{
Q_ASSERT(scope->inUse());
@@ -109,13 +109,13 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, Functio
o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
- o->d()->qmlContext = s.engine->currentContext()->newQmlContext(o, qml)->getPointer();
+ o->d()->qmlContext = s.engine->currentContext()->newQmlContext(o, qml)->getPointer()->d();
s.engine->popContext();
}
Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Object *qml)
: Heap::FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false)
- , qml(qml)
+ , qml(qml->d())
{
Q_ASSERT(scope->inUse());
@@ -127,7 +127,7 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Ob
o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
- o->d()->qmlContext = s.engine->currentContext()->newQmlContext(o, qml)->getPointer();
+ o->d()->qmlContext = s.engine->currentContext()->newQmlContext(o, qml)->getPointer()->d();
s.engine->popContext();
}
@@ -141,7 +141,7 @@ ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *)
if (!This->function())
return QV4::Encode::undefined();
- CallContext *ctx = This->d()->qmlContext;
+ Scoped<CallContext> ctx(scope, This->d()->qmlContext);
std::fill(ctx->d()->locals, ctx->d()->locals + ctx->d()->function->varCount(), Primitive::undefinedValue());
engine->pushContext(ctx);
ScopedValue result(scope, This->function()->code(ctx, This->function()->codeData));
@@ -174,6 +174,7 @@ Returned<FunctionObject> *QmlBindingWrapper::createQmlCallableForFunction(QQmlCo
QV4::Scope valueScope(engine);
QV4::ScopedObject qmlScopeObject(valueScope, QV4::QmlContextWrapper::qmlScope(engine->v8Engine, qmlContext, scopeObject));
QV4::Scoped<QV4::QmlBindingWrapper> wrapper(valueScope, engine->memoryManager->alloc<QV4::QmlBindingWrapper>(engine->rootContext, qmlScopeObject));
+ QV4::Scoped<CallContext> wrapperContext(valueScope, wrapper->context());
if (!signalParameters.isEmpty()) {
if (error)
@@ -182,7 +183,7 @@ Returned<FunctionObject> *QmlBindingWrapper::createQmlCallableForFunction(QQmlCo
QV4::ScopedString s(valueScope);
int index = 0;
foreach (const QByteArray &param, signalParameters) {
- QV4::ScopedFunctionObject g(valueScope, engine->memoryManager->alloc<QV4::IndexedBuiltinFunction>(wrapper->context(), index++, signalParameterGetter));
+ QV4::ScopedFunctionObject g(valueScope, engine->memoryManager->alloc<QV4::IndexedBuiltinFunction>(wrapperContext, index++, signalParameterGetter));
p->setGetter(g);
p->setSetter(0);
s = engine->newString(QString::fromUtf8(param));
@@ -190,7 +191,7 @@ Returned<FunctionObject> *QmlBindingWrapper::createQmlCallableForFunction(QQmlCo
}
}
- QV4::ScopedFunctionObject function(valueScope, QV4::FunctionObject::createScriptFunction(wrapper->context(), runtimeFunction));
+ QV4::ScopedFunctionObject function(valueScope, QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction));
return function->asReturned<FunctionObject>();
}
diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h
index 3379e204e1..3da8cf0269 100644
--- a/src/qml/jsruntime/qv4script_p.h
+++ b/src/qml/jsruntime/qv4script_p.h
@@ -76,8 +76,8 @@ struct QmlBindingWrapper : Heap::FunctionObject {
QmlBindingWrapper(QV4::ExecutionContext *scope, Function *f, QV4::Object *qml);
// Constructor for QML functions and signal handlers, resulting binding wrapper is not callable!
QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Object *qml);
- QV4::Object *qml;
- QV4::CallContext *qmlContext;
+ Object *qml;
+ CallContext *qmlContext;
};
}
@@ -88,7 +88,7 @@ struct Q_QML_EXPORT QmlBindingWrapper : FunctionObject {
static ReturnedValue call(Managed *that, CallData *);
static void markObjects(Heap::Base *m, ExecutionEngine *e);
- CallContext *context() const { return d()->qmlContext; }
+ Heap::CallContext *context() const { return d()->qmlContext; }
static Returned<FunctionObject> *createQmlCallableForFunction(QQmlContextData *qmlContext, QObject *scopeObject, QV4::Function *runtimeFunction,
const QList<QByteArray> &signalParameters = QList<QByteArray>(), QString *error = 0);
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 42cac66fbd..dcf5f0cee4 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -267,7 +267,8 @@ bool QQmlObjectCreator::populateDeferredProperties(QObject *instance)
QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject));
QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(v4->rootContext, qmlScope));
- QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context();
+ // ### GC
+ QV4::ExecutionContext *qmlContext = QV4::ScopedContext(valueScope, qmlBindingWrapper->context()).getPointer();
qSwap(_qmlContext, qmlContext);
@@ -1177,7 +1178,8 @@ QObject *QQmlObjectCreator::createInstance(int index, QObject *parent, bool isCo
QV4::Scope valueScope(v4);
QV4::ScopedObject qmlScope(valueScope, QV4::QmlContextWrapper::qmlScope(QV8Engine::get(engine), context, _scopeObject));
QV4::Scoped<QV4::QmlBindingWrapper> qmlBindingWrapper(valueScope, v4->memoryManager->alloc<QV4::QmlBindingWrapper>(v4->rootContext, qmlScope));
- QV4::ExecutionContext *qmlContext = qmlBindingWrapper->context();
+ // ### GC
+ QV4::ExecutionContext *qmlContext = QV4::ScopedContext(valueScope, qmlBindingWrapper->context()).getPointer();
qSwap(_qmlContext, qmlContext);