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