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