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