mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 05:33:10 +02:00
add support to abort evaluation of long running scripts on shutdown
This commit is contained in:
parent
a21bc66fa3
commit
48e63ea828
1 changed files with 4 additions and 2 deletions
|
@ -201,6 +201,8 @@ void ScriptEngine::waitTillDoneRunning() {
|
|||
// we want the application thread to continue to process events, because the scripts will likely need to
|
||||
// marshall messages across to the main thread. For example if they access Settings or Menu in any of their
|
||||
// shutdown code.
|
||||
QString scriptName = getFilename();
|
||||
|
||||
auto startedWaiting = usecTimestampNow();
|
||||
while (thread()->isRunning()) {
|
||||
// process events for the main application thread, allowing invokeMethod calls to pass between threads
|
||||
|
@ -210,14 +212,14 @@ void ScriptEngine::waitTillDoneRunning() {
|
|||
|
||||
// if we've been waiting a second or more, then tell the script engine to stop evaluating
|
||||
if (elapsed > USECS_PER_SECOND) {
|
||||
qDebug() << __FUNCTION__ << "...giving up on evaluation elapsed:" << elapsed << "calling abortEvaluation()";
|
||||
qDebug() << "giving up on evaluation elapsed:" << elapsed << "calling abortEvaluation() script:" << scriptName;
|
||||
abortEvaluation();
|
||||
}
|
||||
|
||||
// if we've been waiting for more than 5 seconds then we should be more aggessive about stopping
|
||||
static const auto WAITING_TOO_LONG = USECS_PER_SECOND * 5;
|
||||
if (elapsed > WAITING_TOO_LONG) {
|
||||
qDebug() << __FUNCTION__ << "...giving up on thread elapsed:" << elapsed << "calling thread->quit()";
|
||||
qDebug() << "giving up on thread elapsed:" << elapsed << "calling thread->quit() script:" << scriptName;
|
||||
thread()->quit();
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue