History

More gettimeofday cleanup

Atlante45 committed 12 years ago

Commit f7f30e11 parent ab76e6a14 files · +57 −168Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 14 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+3−3
@@ -273,8 +273,8 @@ void ScriptEngine::run() { · 272 unmodified lines
273273 qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
274274 }
275275
276− timeval startTime;
277− gettimeofday(&startTime, NULL);
276+ QElapsedTimer startTime;
277+ startTime.start();
278278
279279 int thisFrame = 0;
280280
@@ -283,7 +283,7 @@ void ScriptEngine::run() { · 2 unmodified lines
283283 qint64 lastUpdate = usecTimestampNow();
284284
285285 while (!_isFinished) {
286− int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - usecTimestampNow();
286+ int usecToSleep = (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - startTime.nsecsElapsed() / 1000; // nsec to usec
287287 if (usecToSleep > 0) {
288288 usleep(usecToSleep);
289289 }