Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 54 files). Show all
Unified · Split
| @@ -292,8 +292,8 @@ void ScriptEngine::run() { · 291 unmodified lines | |||
| 292 | emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString()); | 292 | emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString()); |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | timeval startTime; | 295 | QElapsedTimer startTime; |
| 296 | gettimeofday(&startTime, NULL); | 296 | startTime.start(); |
| 297 | 297 | ||
| 298 | int thisFrame = 0; | 298 | int thisFrame = 0; |
| 299 | 299 | ||
| @@ -302,7 +302,7 @@ void ScriptEngine::run() { · 2 unmodified lines | |||
| 302 | qint64 lastUpdate = usecTimestampNow(); | 302 | qint64 lastUpdate = usecTimestampNow(); |
| 303 | 303 | ||
| 304 | while (!_isFinished) { | 304 | while (!_isFinished) { |
| 305 | int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - usecTimestampNow(); | 305 | int usecToSleep = (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - startTime.nsecsElapsed() / 1000; // nsec to usec |
| 306 | if (usecToSleep > 0) { | 306 | if (usecToSleep > 0) { |
| 307 | usleep(usecToSleep); | 307 | usleep(usecToSleep); |
| 308 | } | 308 | } |