From 7a13c867aed486e090a1c851372249515919b04d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 17 Jul 2015 11:18:11 -0700 Subject: [PATCH] quit the ScriptEngine thread once the script is done --- interface/src/Application.cpp | 9 ++++++--- libraries/script-engine/src/ScriptEngine.cpp | 6 ------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b4b11b105c..1d215f680a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4111,10 +4111,13 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri // when the worker thread is started, call our engine's run.. connect(workerThread, &QThread::started, scriptEngine, &ScriptEngine::run); - + // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue - connect(scriptEngine, SIGNAL(doneRunning()), scriptEngine, SLOT(deleteLater())); - connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); + connect(scriptEngine, &ScriptEngine::doneRunning, scriptEngine, &ScriptEngine::deleteLater()); + connect(workerThread, &QThread::finished, workerThread, &Qthread::deleteLater); + + // tell the thread to stop when the script engine is done + connect(scriptEngine, &ScriptEngine::destroyed, workerThread, &QThread::quit); auto nodeList = DependencyManager::get(); connect(nodeList.data(), &NodeList::nodeKilled, scriptEngine, &ScriptEngine::nodeKilled); diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index e99072de71..7bb62a01ab 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -720,12 +720,6 @@ void ScriptEngine::run() { } } - // If we were on a thread, then wait till it's done - // Unless we're an assignment-client, in which case that's handled for us - if (thread() && !_isAgent) { - thread()->quit(); - } - emit finished(_fileNameString); _isRunning = false;