Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 3 files). Show all
Unified · Split
| @@ -352,6 +352,13 @@ QStringList ScriptEngines::getRunningScripts() { · 351 unmodified lines | ||
| 352 | 352 | void ScriptEngines::stopAllScripts(bool restart) { |
| 353 | 353 | QVector<QString> toReload; |
| 354 | 354 | QReadLocker lock(&_scriptEnginesHashLock); |
| 355 | + | |
| 356 | + if (_isReloading) { | |
| 357 | + return; | |
| 358 | + } else { | |
| 359 | + _isReloading = true; | |
| 360 | + } | |
| 361 | + | |
| 355 | 362 | for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); |
| 356 | 363 | it != _scriptEnginesHash.constEnd(); it++) { |
| 357 | 364 | ScriptEngine *scriptEngine = it.value(); |
| @@ -371,7 +378,7 @@ void ScriptEngines::stopAllScripts(bool restart) { · 13 unmodified lines | ||
| 371 | 378 | } |
| 372 | 379 | // wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before |
| 373 | 380 | // triggering reload of any Client scripts / Entity scripts |
| 374 | − QTimer::singleShot(500, this, [=]() { | |
| 381 | + QTimer::singleShot(1000, this, [=]() { | |
| 375 | 382 | for(const auto &scriptName : toReload) { |
| 376 | 383 | auto scriptEngine = getScriptEngine(scriptName); |
| 377 | 384 | if (scriptEngine && !scriptEngine->isFinished()) { |
| @@ -386,6 +393,7 @@ void ScriptEngines::stopAllScripts(bool restart) { · 8 unmodified lines | ||
| 386 | 393 | qCDebug(scriptengine) << "stopAllScripts -- emitting scriptsReloading"; |
| 387 | 394 | emit scriptsReloading(); |
| 388 | 395 | } |
| 396 | + _isReloading = false; | |
| 389 | 397 | }); |
| 390 | 398 | } |
| 391 | 399 | |