Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 14 files). Show all
Unified · Split
| @@ -273,8 +273,8 @@ void ScriptEngine::run() { · 272 unmodified lines | |||
| 273 | qDebug() << "Uncaught exception at line" << line << ":" << result.toString(); | 273 | qDebug() << "Uncaught exception at line" << line << ":" << result.toString(); |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | timeval startTime; | 276 | QElapsedTimer startTime; |
| 277 | gettimeofday(&startTime, NULL); | 277 | startTime.start(); |
| 278 | 278 | ||
| 279 | int thisFrame = 0; | 279 | int thisFrame = 0; |
| 280 | 280 | ||
| @@ -283,7 +283,7 @@ void ScriptEngine::run() { · 2 unmodified lines | |||
| 283 | qint64 lastUpdate = usecTimestampNow(); | 283 | qint64 lastUpdate = usecTimestampNow(); |
| 284 | 284 | ||
| 285 | while (!_isFinished) { | 285 | 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 |
| 287 | if (usecToSleep > 0) { | 287 | if (usecToSleep > 0) { |
| 288 | usleep(usecToSleep); | 288 | usleep(usecToSleep); |
| 289 | } | 289 | } |