History

Merge pull request #10755 from seefo/fb5278

Fixed an issue where toolbar buttons duplicated themselves when reloading scripts

Brad Hefta-Gaub committed 9 years ago

Commit 7668fbb2 parents 197006e 00a3fc73 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
@@ -356,6 +356,13 @@ QStringList ScriptEngines::getRunningScripts() { · 355 unmodified lines
356356 void ScriptEngines::stopAllScripts(bool restart) {
357357 QVector<QString> toReload;
358358 QReadLocker lock(&_scriptEnginesHashLock);
359+
360+ if (_isReloading) {
361+ return;
362+ } else {
363+ _isReloading = true;
364+ }
365+
359366 for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
360367 it != _scriptEnginesHash.constEnd(); it++) {
361368 ScriptEngine *scriptEngine = it.value();
@@ -375,7 +382,7 @@ void ScriptEngines::stopAllScripts(bool restart) { · 13 unmodified lines
375382 }
376383 // wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before
377384 // triggering reload of any Client scripts / Entity scripts
378− QTimer::singleShot(500, this, [=]() {
385+ QTimer::singleShot(1000, this, [=]() {
379386 for(const auto &scriptName : toReload) {
380387 auto scriptEngine = getScriptEngine(scriptName);
381388 if (scriptEngine && !scriptEngine->isFinished()) {
@@ -390,6 +397,7 @@ void ScriptEngines::stopAllScripts(bool restart) { · 8 unmodified lines
390397 qCDebug(scriptengine) << "stopAllScripts -- emitting scriptsReloading";
391398 emit scriptsReloading();
392399 }
400+ _isReloading = false;
393401 });
394402 }
395403