From af52be78600054cc8468f10ab18b167bfbce8b8e Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 16 Dec 2013 09:32:01 -0800 Subject: [PATCH] tweaks to script engine shutdown behavior --- interface/src/Application.cpp | 6 ++++-- libraries/scriptengine/src/ScriptEngine.cpp | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index dc57730aa0..a004f19238 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -263,6 +263,8 @@ Application::~Application() { delete _settings; delete _followMode; delete _glWidget; + + qDebug() << "DONE... Application::~Application()\n"; } void Application::restoreSizeAndPosition() { @@ -4435,8 +4437,8 @@ void Application::loadScript() { connect(scriptEngine, SIGNAL(finished()), workerThread, SLOT(quit())); // when the thread is terminated, add both scriptEngine and thread to the deleteLater queue - connect(workerThread, SIGNAL(terminated()), scriptEngine, SLOT(deleteLater())); - connect(workerThread, SIGNAL(terminated()), workerThread, SLOT(deleteLater())); + connect(workerThread, SIGNAL(finished()), scriptEngine, SLOT(deleteLater())); + connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater())); // when the application is about to quit, stop our script engine so it unwinds properly connect(this, SIGNAL(aboutToQuit()), scriptEngine, SLOT(stop())); diff --git a/libraries/scriptengine/src/ScriptEngine.cpp b/libraries/scriptengine/src/ScriptEngine.cpp index 24c72aaf65..62b729a1df 100644 --- a/libraries/scriptengine/src/ScriptEngine.cpp +++ b/libraries/scriptengine/src/ScriptEngine.cpp @@ -102,7 +102,15 @@ void ScriptEngine::run() { usleep(usecToSleep); } + if (_isFinished) { + break; + } + QCoreApplication::processEvents(); + + if (_isFinished) { + break; + } bool willSendVisualDataCallBack = false; if (_voxelScriptingInterface.getVoxelPacketSender()->serversExist()) { @@ -138,5 +146,6 @@ void ScriptEngine::run() { } } cleanMenuItems(); + qDebug() << "About to emit finished...\n"; emit finished(); }