Merge pull request #13377 from danteruiz/fix-double-scripts-on-reload

prevent having more than one instance of a script running after reloading the script
This commit is contained in:
Seth Alves 2018-06-15 17:17:35 -07:00 committed by GitHub
commit 3c081c4bf8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -432,10 +432,13 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) {
ScriptEngine::Type type = scriptEngine->getType();
auto scriptCache = DependencyManager::get<ScriptCache>();
scriptCache->deleteScript(scriptURL);
connect(scriptEngine.data(), &ScriptEngine::finished,
this, [this, isUserLoaded, type](QString scriptName, ScriptEnginePointer engine) {
reloadScript(scriptName, isUserLoaded)->setType(type);
});
if (!scriptEngine->isStopping()) {
connect(scriptEngine.data(), &ScriptEngine::finished,
this, [this, isUserLoaded, type](QString scriptName, ScriptEnginePointer engine) {
reloadScript(scriptName, isUserLoaded)->setType(type);
});
}
}
scriptEngine->stop();
stoppedScript = true;