diff options
author | Tor Arne Vestbø <tor.arne.vestbo@nokia.com> | 2009-08-03 18:06:34 (GMT) |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@nokia.com> | 2009-08-03 18:18:05 (GMT) |
commit | e2852e547216562751a5d05ebdfbd001113cc9b6 (patch) | |
tree | 9be1efb141753fdbe3b6887c6049544f64b674f4 /src/script/api/qscriptengine.cpp | |
parent | f3a7266cb4793f933ea8c7d2c73c736e022b754a (diff) | |
download | Qt-e2852e547216562751a5d05ebdfbd001113cc9b6.zip Qt-e2852e547216562751a5d05ebdfbd001113cc9b6.tar.gz Qt-e2852e547216562751a5d05ebdfbd001113cc9b6.tar.bz2 |
Implement QScriptEngine::abortEvaluation()
We store the abort-state in the TimeoutChecker, since that's
where we'll mostly access it, but the abort result is stored
in the QScriptEngine's d-pointer.
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index f60d0af..97d8061 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -417,9 +417,12 @@ public: TimeoutCheckerProxy(const JSC::TimeoutChecker& originalChecker) : JSC::TimeoutChecker(originalChecker) , m_shouldProcessEvents(false) + , m_shouldAbortEvaluation(false) {} void setShouldProcessEvents(bool shouldProcess) { m_shouldProcessEvents = shouldProcess; } + void setShouldAbort(bool shouldAbort) { m_shouldAbortEvaluation = shouldAbort; } + bool shouldAbort() { return m_shouldAbortEvaluation; } virtual bool didTimeOut(JSC::ExecState* exec) { @@ -429,11 +432,12 @@ public: if (m_shouldProcessEvents) QCoreApplication::processEvents(); - return false; + return m_shouldAbortEvaluation; } private: bool m_shouldProcessEvents; + bool m_shouldAbortEvaluation; }; static int toDigit(char c) @@ -2278,6 +2282,12 @@ QScriptValue QScriptEngine::evaluate(const QString &program, const QString &file JSC::JSValue exceptionValue; JSC::JSValue result = exec->interpreter()->execute(evalNode.get(), exec, thisObject, exec->scopeChain(), &exceptionValue); + if (dynamic_cast<QScript::TimeoutCheckerProxy*>(d->globalData->timeoutChecker)->shouldAbort()) { + if (d->abortResult.isError()) + exec->setException(d->scriptValueToJSCValue(d->abortResult)); + return d->abortResult; + } + if (exceptionValue) { exec->setException(exceptionValue); return d->scriptValueFromJSCValue(exceptionValue); @@ -3541,8 +3551,10 @@ bool QScriptEngine::isEvaluating() const */ void QScriptEngine::abortEvaluation(const QScriptValue &result) { - qWarning("QScriptEngine::abortEvaluation() not implemented"); - Q_UNUSED(result); + Q_D(QScriptEngine); + + dynamic_cast<QScript::TimeoutCheckerProxy*>(d->globalData->timeoutChecker)->setShouldAbort(true); + d->abortResult = result; } #ifndef QT_NO_QOBJECT |