prevent have more than one instance of a script after reloading script

This commit is contained in:
Dante Ruiz 2018-06-14 14:00:40 -07:00
parent 4f561b00da
commit 8b4b95f890

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;