mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-04 19:06:10 +02:00
Merge pull request #7926 from zzmp/fix/debug-script-crash
fix crash on shutdown in debug
This commit is contained in:
commit
2062291810
1 changed files with 11 additions and 7 deletions
|
@ -294,13 +294,6 @@ void ScriptEngine::waitTillDoneRunning() {
|
||||||
|
|
||||||
auto startedWaiting = usecTimestampNow();
|
auto startedWaiting = usecTimestampNow();
|
||||||
while (workerThread->isRunning()) {
|
while (workerThread->isRunning()) {
|
||||||
// NOTE: This will be called on the main application thread from stopAllScripts.
|
|
||||||
// The application thread will need to continue to process events, because
|
|
||||||
// the scripts will likely need to marshall messages across to the main thread, e.g.
|
|
||||||
// if they access Settings or Menu in any of their shutdown code. So:
|
|
||||||
// Process events for the main application thread, allowing invokeMethod calls to pass between threads.
|
|
||||||
QCoreApplication::processEvents();
|
|
||||||
|
|
||||||
// If the final evaluation takes too long, then tell the script engine to stop running
|
// If the final evaluation takes too long, then tell the script engine to stop running
|
||||||
auto elapsedUsecs = usecTimestampNow() - startedWaiting;
|
auto elapsedUsecs = usecTimestampNow() - startedWaiting;
|
||||||
static const auto MAX_SCRIPT_EVALUATION_TIME = USECS_PER_SECOND;
|
static const auto MAX_SCRIPT_EVALUATION_TIME = USECS_PER_SECOND;
|
||||||
|
@ -326,6 +319,17 @@ void ScriptEngine::waitTillDoneRunning() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: This will be called on the main application thread from stopAllScripts.
|
||||||
|
// The application thread will need to continue to process events, because
|
||||||
|
// the scripts will likely need to marshall messages across to the main thread, e.g.
|
||||||
|
// if they access Settings or Menu in any of their shutdown code. So:
|
||||||
|
// Process events for the main application thread, allowing invokeMethod calls to pass between threads.
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
// In some cases (debugging), processEvents may give the thread enough time to shut down, so recheck it.
|
||||||
|
if (!thread()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid a pure busy wait
|
// Avoid a pure busy wait
|
||||||
QThread::yieldCurrentThread();
|
QThread::yieldCurrentThread();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue