Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 15 files). Show all
Unified · Split
| @@ -1087,6 +1087,12 @@ QObject* ScriptEngine::setupTimerWithInterval(const QScriptValue& function, int · 1086 unmodified lines | |||
| 1087 | QTimer* newTimer = new QTimer(this); | 1087 | QTimer* newTimer = new QTimer(this); |
| 1088 | newTimer->setSingleShot(isSingleShot); | 1088 | newTimer->setSingleShot(isSingleShot); |
| 1089 | 1089 | ||
| 1090 | // The default timer type is not very accurate below about 200ms http://doc.qt.io/qt-5/qt.html#TimerType-enum | ||
| 1091 | static const int MIN_TIMEOUT_FOR_COARSE_TIMER = 200; | ||
| 1092 | if (intervalMS < MIN_TIMEOUT_FOR_COARSE_TIMER) { | ||
| 1093 | newTimer->setTimerType(Qt::PreciseTimer); | ||
| 1094 | } | ||
| 1095 | |||
| 1090 | connect(newTimer, &QTimer::timeout, this, &ScriptEngine::timerFired); | 1096 | connect(newTimer, &QTimer::timeout, this, &ScriptEngine::timerFired); |
| 1091 | 1097 | ||
| 1092 | // make sure the timer stops when the script does | 1098 | // make sure the timer stops when the script does |