aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4script.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2017-09-15 10:14:58 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-09-15 10:41:08 +0000
commitacd206e317fd92f20aa4985f35288f793d05f3ac (patch)
tree0169ec7fb4adf7300c4e47f2a5372aa0b76b41a9 /src/qml/jsruntime/qv4script.cpp
parentdfb3ba6329147f0d0ea22d62b9903246ce2934bd (diff)
Fix CallData setup for Script::run
By calling JSCall with an ExecutionContext as first parameter, the compiler would implicitly create a temporary Scope object in order to be able to do the call. However, the scope would then wipe the stack when it is being destructed. So subsequently retrieving argc would always result in 0 arguments. To prevent accidents like this, all Scope constructors are now explicit, and the QV4::Script's ExecutionContext is renamed from scope to context. Change-Id: Iea7930748a0544382a20b6617fa9818a8a2bea7f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4script.cpp')
-rw-r--r--src/qml/jsruntime/qv4script.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index c3200fbcea..9850734aa1 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -61,7 +61,7 @@
using namespace QV4;
Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit)
- : line(1), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false)
+ : line(1), column(0), context(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false)
, compilationUnit(compilationUnit), vmFunction(0), parseAsBinding(true)
{
if (qml)
@@ -85,7 +85,7 @@ void Script::parse()
parsed = true;
- ExecutionEngine *v4 = scope->engine();
+ ExecutionEngine *v4 = context->engine();
Scope valueScope(v4);
Module module(v4->debugger() != 0);
@@ -143,18 +143,18 @@ ReturnedValue Script::run()
if (!vmFunction)
return Encode::undefined();
- QV4::ExecutionEngine *engine = scope->engine();
+ QV4::ExecutionEngine *engine = context->engine();
QV4::Scope valueScope(engine);
if (qmlContext.isUndefined()) {
TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, vmFunction);
- ContextStateSaver stateSaver(valueScope, scope);
- scope->d()->v4Function = vmFunction;
+ ContextStateSaver stateSaver(valueScope, context);
+ context->d()->v4Function = vmFunction;
- QV4::JSCall jsCall(scope, nullptr);
+ QV4::JSCall jsCall(valueScope, nullptr);
jsCall->thisObject = engine->globalObject;
- jsCall->context = *scope;
+ jsCall->context = *context;
return vmFunction->call(jsCall);
} else {
Scoped<QmlContext> qml(valueScope, qmlContext.value());