This fixes issue #2159:
Showing the changes to libraries/script-engine/src/ScriptManager.cpp (1 of 2 files). Show all
Unified · Split
| @@ -1281,7 +1281,20 @@ QTimer* ScriptManager::setupTimerWithInterval(const ScriptValue& function, int i · 1280 unmodified lines | ||
| 1281 | 1281 | CallbackData timerData = { function, currentEntityIdentifier, currentSandboxURL }; |
| 1282 | 1282 | _timerFunctionMap.insert(newTimer, timerData); |
| 1283 | 1283 | |
| 1284 | − newTimer->start(intervalMS); | |
| 1284 | + if (intervalMS < 0) { | |
| 1285 | + int lineNumber = -1; | |
| 1286 | + QString fileName = getFilename(); | |
| 1287 | + auto context = _engine->currentContext(); | |
| 1288 | + if (context) { | |
| 1289 | + lineNumber = context->currentLineNumber(); | |
| 1290 | + fileName = context->currentFileName(); | |
| 1291 | + } | |
| 1292 | + | |
| 1293 | + scriptWarningMessage("Script.setInterval() was passed negative value " + QString::number(intervalMS) + ". Ignored, timer not started. Parent script:" + getFilename(), fileName, lineNumber); | |
| 1294 | + } else { | |
| 1295 | + newTimer->start(intervalMS); | |
| 1296 | + } | |
| 1297 | + | |
| 1285 | 1298 | return newTimer; |
| 1286 | 1299 | } |
| 1287 | 1300 | |