Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -4357,16 +4357,24 @@ void Application::scriptFinished(const QString& scriptName) { · 4356 unmodified lines | ||
| 4357 | 4357 | } |
| 4358 | 4358 | |
| 4359 | 4359 | 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 | + } | |
| 4361 | 4370 | |
| 4362 | − // stops all current running scripts | |
| 4371 | + // Stop and possibly restart all currently running scripts | |
| 4363 | 4372 | for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); |
| 4364 | 4373 | it != _scriptEnginesHash.constEnd(); it++) { |
| 4365 | 4374 | if (it.value()->isFinished()) { |
| 4366 | 4375 | continue; |
| 4367 | 4376 | } |
| 4368 | 4377 | if (restart && it.value()->isUserLoaded()) { |
| 4369 | − scriptCache->deleteScript(it.key()); | |
| 4370 | 4378 | connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&))); |
| 4371 | 4379 | } |
| 4372 | 4380 | it.value()->stop(); |