From d74da0f5a69e73bda91bb4270169da86b22a37b3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 15 Oct 2015 14:31:52 +0200 Subject: Properly resolve the context to create mutable bindings on This fixes a regression introduced in 5.5, where eval() calls in strict mode would still modify outer properties. Change-Id: I3ab70b45217eea16da68a4537e3c107b76794f2c Reviewed-by: Simon Hausmann Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4context.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/qml/jsruntime') diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 403beacf39..007bf92639 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -114,23 +114,32 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) Scope scope(this); // find the right context to create the binding on - ScopedObject activation(scope, d()->engine->globalObject); + ScopedObject activation(scope); ScopedContext ctx(scope, this); while (ctx) { switch (ctx->d()->type) { case Heap::ExecutionContext::Type_CallContext: case Heap::ExecutionContext::Type_SimpleCallContext: { Heap::CallContext *c = static_cast(ctx->d()); - if (!c->activation) - c->activation = scope.engine->newObject(); - activation = c->activation; + if (!activation) { + if (!c->activation) + c->activation = scope.engine->newObject(); + activation = c->activation; + } break; } case Heap::ExecutionContext::Type_QmlContext: { + // this is ugly, as it overrides the inner callcontext, but has to stay as long + // as bindings still get their own callcontext Heap::QmlContext *qml = static_cast(ctx->d()); activation = qml->qml; break; } + case Heap::ExecutionContext::Type_GlobalContext: { + if (!activation) + activation = scope.engine->globalObject; + break; + } default: break; } -- cgit v1.2.3