From 1eb03f059ee879b830fc22c151265543b40043a5 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 10 Aug 2009 17:16:24 +0200 Subject: get rid of dynamic casts --- src/script/api/qscriptengine.cpp | 13 +++++++++---- src/script/api/qscriptengine_p.h | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 3ae1502..cc7ead3 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1186,6 +1186,11 @@ void QScriptEnginePrivate::collectGarbage() globalData->heap.collect(); } +QScript::TimeoutCheckerProxy *QScriptEnginePrivate::timeoutChecker() const +{ + return static_cast(globalData->timeoutChecker); +} + #ifndef QT_NO_QOBJECT JSC::JSValue QScriptEnginePrivate::newQObject( @@ -2173,10 +2178,10 @@ 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); + d->timeoutChecker()->setShouldAbort(false); JSC::JSValue result = exec->interpreter()->execute(evalNode.get(), exec, thisObject, exec->scopeChain(), &exceptionValue); - if (dynamic_cast(d->globalData->timeoutChecker)->shouldAbort()) { + if (d->timeoutChecker()->shouldAbort()) { if (d->abortResult.isError()) exec->setException(d->scriptValueToJSCValue(d->abortResult)); return d->abortResult; @@ -3384,7 +3389,7 @@ void QScriptEngine::setProcessEventsInterval(int interval) if (interval > 0) d->globalData->timeoutChecker->setCheckInterval(interval); - dynamic_cast(d->globalData->timeoutChecker)->setShouldProcessEvents(interval > 0); + d->timeoutChecker()->setShouldProcessEvents(interval > 0); } /*! @@ -3434,7 +3439,7 @@ void QScriptEngine::abortEvaluation(const QScriptValue &result) { Q_D(QScriptEngine); - dynamic_cast(d->globalData->timeoutChecker)->setShouldAbort(true); + d->timeoutChecker()->setShouldAbort(true); d->abortResult = result; } diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index 472b0da..1506e7e 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -94,6 +94,7 @@ namespace QScript #ifndef QT_NO_QOBJECT class QObjectData; #endif + class TimeoutCheckerProxy; //some conversion helper functions JSC::UString qtStringToJSCUString(const QString &str); @@ -160,6 +161,8 @@ public: bool isCollecting() const; void collectGarbage(); + QScript::TimeoutCheckerProxy *timeoutChecker() const; + #ifndef QT_NO_QOBJECT JSC::JSValue newQObject(QObject *object, QScriptEngine::ValueOwnership ownership = QScriptEngine::QtOwnership, -- cgit v0.12