History

Redownload scripts that are loaded via Script.load() when reloading all

David Rowe committed 11 years ago

Commit 17f7d761 parent 5dab9771 file · +11 −3Browse files

Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all

Unified · Split

interface/src/Application.cpp+11−3
@@ -4357,16 +4357,24 @@ void Application::scriptFinished(const QString& scriptName) { · 4356 unmodified lines
43574357 }
43584358
43594359 void Application::stopAllScripts(bool restart) {
4360− auto scriptCache = DependencyManager::get<ScriptCache>();
4360+ if (restart) {
4361+ // Delete all running scripts from cache so that they are re-downloaded when they are restarted
4362+ auto scriptCache = DependencyManager::get<ScriptCache>();
4363+ for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
4364+ it != _scriptEnginesHash.constEnd(); it++) {
4365+ if (!it.value()->isFinished()) {
4366+ scriptCache->deleteScript(it.key());
4367+ }
4368+ }
4369+ }
43614370
4362− // stops all current running scripts
4371+ // Stop and possibly restart all currently running scripts
43634372 for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
43644373 it != _scriptEnginesHash.constEnd(); it++) {
43654374 if (it.value()->isFinished()) {
43664375 continue;
43674376 }
43684377 if (restart && it.value()->isUserLoaded()) {
4369− scriptCache->deleteScript(it.key());
43704378 connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&)));
43714379 }
43724380 it.value()->stop();