diff options
-rw-r--r-- | src/declarative/qml/qmlexpression.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 00454a1..77463cd 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -225,12 +225,13 @@ QVariant QmlExpressionPrivate::evalQtScript() ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount, me); QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); - QScriptContext *scriptContext = scriptEngine->pushContext(); - for (int i = ctxtPriv->scopeChain.size() - 1; i > -1; --i) - scriptContext->pushScope(ctxtPriv->scopeChain.at(i)); if (!expressionFunctionValid) { + QScriptContext *scriptContext = scriptEngine->pushContext(); + for (int i = ctxtPriv->scopeChain.size() - 1; i > -1; --i) + scriptContext->pushScope(ctxtPriv->scopeChain.at(i)); + if (expressionRewritten) { expressionFunction = scriptEngine->evaluate(expression, fileName, line); } else { @@ -239,12 +240,13 @@ QVariant QmlExpressionPrivate::evalQtScript() const QString code = rewriteBinding(expression); expressionFunction = scriptEngine->evaluate(code, fileName, line); } + + scriptEngine->popContext(); expressionFunctionValid = true; } QScriptValue svalue = expressionFunction.call(); - if (scriptEngine->hasUncaughtException()) { if (scriptEngine->uncaughtException().isError()){ QScriptValue exception = scriptEngine->uncaughtException(); @@ -301,8 +303,6 @@ QVariant QmlExpressionPrivate::evalQtScript() if (rv.isNull()) rv = svalue.toVariant(); - scriptEngine->popContext(); - return rv; } |