From 8d920689a704be771488d2aae61b69077a7a491f Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 1 Oct 2009 15:47:09 +0200 Subject: Reset timeout-checker before evaluating when processEventsInterval is used When the timeout-checker was not reset, it could take a while (e.g. 1-2 seconds) before the next timeout occurred, depending on what the tick counter happened to be after the previous evaluate(). When a processEventsInterval of e.g. 100 milliseconds has been specified, we want the timeout to happen much sooner, thus we need to reset the checker. This will cause the first timeout to happen quickly, and then at steady intervals (processEventsInterval ms) after that. The tst_QScriptEngine::processEventsWhileRunning() test was sporadically failing due to this issue. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 059b102..fb14940 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2185,6 +2185,8 @@ QScriptValue QScriptEngine::evaluate(const QString &program, const QString &file JSC::JSObject* thisObject = (!thisValue || thisValue.isUndefinedOrNull()) ? exec->dynamicGlobalObject() : thisValue.toObject(exec); JSC::JSValue exceptionValue; d->timeoutChecker()->setShouldAbort(false); + if (d->processEventsInterval > 0) + d->timeoutChecker()->reset(); JSC::JSValue result = exec->interpreter()->execute(&executable, exec, thisObject, exec->scopeChain(), &exceptionValue); if (d->timeoutChecker()->shouldAbort()) { -- cgit v0.12