summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@nokia.com>2009-08-03 18:06:34 (GMT)
committerTor Arne Vestbø <tor.arne.vestbo@nokia.com>2009-08-03 18:18:05 (GMT)
commite2852e547216562751a5d05ebdfbd001113cc9b6 (patch)
tree9be1efb141753fdbe3b6887c6049544f64b674f4 /src
parentf3a7266cb4793f933ea8c7d2c73c736e022b754a (diff)
downloadQt-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')
-rw-r--r--src/script/api/qscriptengine.cpp18
-rw-r--r--src/script/api/qscriptengine_p.h1
2 files changed, 16 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
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index f6d7700..cb56cae 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -225,6 +225,7 @@ public:
QHash<JSC::JSCell*, QBasicAtomicInt> keepAliveValues;
QHash<int, QScriptTypeInfo*> m_typeInfos;
int processEventsInterval;
+ QScriptValue abortResult;
QSet<QString> importedExtensions;
QSet<QString> extensionsBeingImported;