diff options
author | Iikka Eklund <iikka.eklund@digia.com> | 2014-05-20 13:26:14 +0300 |
---|---|---|
committer | Iikka Eklund <iikka.eklund@digia.com> | 2014-05-20 13:26:15 +0300 |
commit | 3ed6361bbaa711c9f3441704659ccb971751b44e (patch) | |
tree | be1e4f03b558b08481a333adb048028b2fa4ff42 /src/qml/jsapi | |
parent | 009ad875f89d7d7bc4447e18c2fbbd485a75e0b5 (diff) | |
parent | 073cde9d21f95a896ffff3abfcc9a9da89175e28 (diff) |
Merge remote-tracking branch 'origin/release' into stable
Change-Id: I939d6b9d10b3f50d9024b80d7a215b8fd04e8d56
Diffstat (limited to 'src/qml/jsapi')
-rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index d05ada481a..9cb727dd63 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -235,7 +235,7 @@ void QJSEngine::collectGarbage() Evaluates \a program, using \a lineNumber as the base line number, and returns the result of the evaluation. - The script code will be evaluated in the current context. + The script code will be evaluated in the context of the global object. The evaluation of \a program can cause an exception in the engine; in this case the return value will be the exception @@ -261,8 +261,11 @@ void QJSEngine::collectGarbage() */ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, int lineNumber) { - QV4::Scope scope(d->m_v4Engine); - QV4::ExecutionContext *ctx = d->m_v4Engine->currentContext(); + QV4::ExecutionEngine *v4 = d->m_v4Engine; + QV4::Scope scope(v4); + QV4::ExecutionContext *ctx = v4->currentContext(); + if (ctx != v4->rootContext) + ctx = v4->pushGlobalContext(); QV4::ScopedValue result(scope); QV4::Script script(ctx, program, fileName, lineNumber); @@ -273,7 +276,9 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in result = script.run(); if (scope.engine->hasException) result = ctx->catchException(); - return new QJSValuePrivate(d->m_v4Engine, result); + if (ctx != v4->rootContext) + v4->popContext(); + return new QJSValuePrivate(v4, result); } /*! |