From 8e580cebef7128666017ba39d41aa620a1d2eddf Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 25 Aug 2009 10:35:35 +1000 Subject: Only need to mess with the scope chain when evaluating. --- src/declarative/qml/qmlexpression.cpp | 12 ++++++------ 1 file 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; } -- cgit v0.12