History

add support to abort evaluation of long running scripts on shutdown

Brad Hefta-Gaub committed 10 years ago

Commit 48e63ea1 parent a21bc661 file · +4 −2Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+4−2
@@ -201,6 +201,8 @@ void ScriptEngine::waitTillDoneRunning() { · 200 unmodified lines
201201 // we want the application thread to continue to process events, because the scripts will likely need to
202202 // marshall messages across to the main thread. For example if they access Settings or Menu in any of their
203203 // shutdown code.
204+ QString scriptName = getFilename();
205+
204206 auto startedWaiting = usecTimestampNow();
205207 while (thread()->isRunning()) {
206208 // process events for the main application thread, allowing invokeMethod calls to pass between threads
@@ -210,14 +212,14 @@ void ScriptEngine::waitTillDoneRunning() { · 3 unmodified lines
210212
211213 // if we've been waiting a second or more, then tell the script engine to stop evaluating
212214 if (elapsed > USECS_PER_SECOND) {
213− qDebug() << __FUNCTION__ << "...giving up on evaluation elapsed:" << elapsed << "calling abortEvaluation()";
215+ qDebug() << "giving up on evaluation elapsed:" << elapsed << "calling abortEvaluation() script:" << scriptName;
214216 abortEvaluation();
215217 }
216218
217219 // if we've been waiting for more than 5 seconds then we should be more aggessive about stopping
218220 static const auto WAITING_TOO_LONG = USECS_PER_SECOND * 5;
219221 if (elapsed > WAITING_TOO_LONG) {
220− qDebug() << __FUNCTION__ << "...giving up on thread elapsed:" << elapsed << "calling thread->quit()";
222+ qDebug() << "giving up on thread elapsed:" << elapsed << "calling thread->quit() script:" << scriptName;
221223 thread()->quit();
222224 break;
223225 }