History

audit use of QTimer intervals to make sure we're using Qt::PreciseTimer when appropriate

Brad Hefta-Gaub committed 9 years ago

Commit a72f6011 parent b56a15b15 files · +35 −21Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+6−0
@@ -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 does1098 // make sure the timer stops when the script does