From 175b1689c9e173db62eb5612c7076531354e5252 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Tue, 4 Aug 2009 17:35:45 +0200 Subject: clear abort flag when we start a new evaluate Otherwise evaluate() would _always_ return the value previously passed to abortEvaluation(), once a script had been aborted. --- src/script/api/qscriptengine.cpp | 1 + tests/auto/qscriptengine/tst_qscriptengine.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 179a49f..3378da9 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2150,6 +2150,7 @@ QScriptValue QScriptEngine::evaluate(const QString &program, const QString &file JSC::JSValue thisValue = d->thisForContext(exec); JSC::JSObject* thisObject = (!thisValue || thisValue.isUndefinedOrNull()) ? exec->dynamicGlobalObject() : thisValue.toObject(exec); JSC::JSValue exceptionValue; + dynamic_cast(d->globalData->timeoutChecker)->setShouldAbort(false); JSC::JSValue result = exec->interpreter()->execute(evalNode.get(), exec, thisObject, exec->scopeChain(), &exceptionValue); if (dynamic_cast(d->globalData->timeoutChecker)->shouldAbort()) { diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index f7bac56..06be924 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -2536,6 +2536,13 @@ void tst_QScriptEngine::abortEvaluation() eng.abortEvaluation(); QVERIFY(!eng.hasUncaughtException()); + eng.abortEvaluation(123); + { + QScriptValue ret = eng.evaluate("'ciao'"); + QVERIFY(ret.isString()); + QCOMPARE(ret.toString(), QString::fromLatin1("ciao")); + } + EventReceiver3 receiver(&eng); eng.setProcessEventsInterval(100); -- cgit v0.12