set isStopping on other calls to stop

This commit is contained in:
Seth Alves 2016-05-19 16:15:33 -07:00
parent 9ad488ba7b
commit 3f5ed4bef8

View file

@ -160,6 +160,7 @@ void ScriptEngines::shutdownScripting() {
scriptEngine->disconnect(this); scriptEngine->disconnect(this);
// Gracefully stop the engine's scripting thread // Gracefully stop the engine's scripting thread
scriptEngine->setIsStopping();
scriptEngine->stop(); scriptEngine->stop();
// We need to wait for the engine to be done running before we proceed, because we don't // We need to wait for the engine to be done running before we proceed, because we don't
@ -353,7 +354,6 @@ void ScriptEngines::stopAllScripts(bool restart) {
} }
it.value()->setIsStopping(); it.value()->setIsStopping();
QMetaObject::invokeMethod(it.value(), "stop"); QMetaObject::invokeMethod(it.value(), "stop");
//it.value()->stop();
qCDebug(scriptengine) << "stopping script..." << it.key(); qCDebug(scriptengine) << "stopping script..." << it.key();
} }
} }
@ -370,13 +370,13 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) {
if (_scriptEnginesHash.contains(scriptURL)) { if (_scriptEnginesHash.contains(scriptURL)) {
ScriptEngine* scriptEngine = _scriptEnginesHash[scriptURL]; ScriptEngine* scriptEngine = _scriptEnginesHash[scriptURL];
if (restart) { if (restart) {
scriptEngine->setIsStopping();
auto scriptCache = DependencyManager::get<ScriptCache>(); auto scriptCache = DependencyManager::get<ScriptCache>();
scriptCache->deleteScript(scriptURL); scriptCache->deleteScript(scriptURL);
connect(scriptEngine, &ScriptEngine::finished, this, [this](QString scriptName, ScriptEngine* engine) { connect(scriptEngine, &ScriptEngine::finished, this, [this](QString scriptName, ScriptEngine* engine) {
reloadScript(scriptName); reloadScript(scriptName);
}); });
} }
scriptEngine->setIsStopping();
scriptEngine->stop(); scriptEngine->stop();
stoppedScript = true; stoppedScript = true;
qCDebug(scriptengine) << "stopping script..." << scriptURL; qCDebug(scriptengine) << "stopping script..." << scriptURL;