History

Fixed an issue where toolbar buttons duplicated themselves when reloading scripts

seefo committed 9 years ago

Commit 00a3fc71 parent 07fefdc3 files · +21 −4Browse files

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

Unified · Split

libraries/script-engine/src/ScriptEngines.cpp+9−1
@@ -352,6 +352,13 @@ QStringList ScriptEngines::getRunningScripts() { · 351 unmodified lines
352352 void ScriptEngines::stopAllScripts(bool restart) {
353353 QVector<QString> toReload;
354354 QReadLocker lock(&_scriptEnginesHashLock);
355+
356+ if (_isReloading) {
357+ return;
358+ } else {
359+ _isReloading = true;
360+ }
361+
355362 for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
356363 it != _scriptEnginesHash.constEnd(); it++) {
357364 ScriptEngine *scriptEngine = it.value();
@@ -371,7 +378,7 @@ void ScriptEngines::stopAllScripts(bool restart) { · 13 unmodified lines
371378 }
372379 // wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before
373380 // triggering reload of any Client scripts / Entity scripts
374− QTimer::singleShot(500, this, [=]() {
381+ QTimer::singleShot(1000, this, [=]() {
375382 for(const auto &scriptName : toReload) {
376383 auto scriptEngine = getScriptEngine(scriptName);
377384 if (scriptEngine && !scriptEngine->isFinished()) {
@@ -386,6 +393,7 @@ void ScriptEngines::stopAllScripts(bool restart) { · 8 unmodified lines
386393 qCDebug(scriptengine) << "stopAllScripts -- emitting scriptsReloading";
387394 emit scriptsReloading();
388395 }
396+ _isReloading = false;
389397 });
390398 }
391399