Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 126 files). Show all
Unified · Split
| @@ -294,13 +294,6 @@ void ScriptEngine::waitTillDoneRunning() { · 293 unmodified lines | ||
| 294 | 294 | |
| 295 | 295 | auto startedWaiting = usecTimestampNow(); |
| 296 | 296 | while (workerThread->isRunning()) { |
| 297 | − // NOTE: This will be called on the main application thread from stopAllScripts. | |
| 298 | − // The application thread will need to continue to process events, because | |
| 299 | − // the scripts will likely need to marshall messages across to the main thread, e.g. | |
| 300 | − // if they access Settings or Menu in any of their shutdown code. So: | |
| 301 | − // Process events for the main application thread, allowing invokeMethod calls to pass between threads. | |
| 302 | − QCoreApplication::processEvents(); | |
| 303 | − | |
| 304 | 297 | // If the final evaluation takes too long, then tell the script engine to stop running |
| 305 | 298 | auto elapsedUsecs = usecTimestampNow() - startedWaiting; |
| 306 | 299 | static const auto MAX_SCRIPT_EVALUATION_TIME = USECS_PER_SECOND; |
| @@ -326,6 +319,17 @@ void ScriptEngine::waitTillDoneRunning() { · 19 unmodified lines | ||
| 326 | 319 | } |
| 327 | 320 | } |
| 328 | 321 | |
| 322 | + // NOTE: This will be called on the main application thread from stopAllScripts. | |
| 323 | + // The application thread will need to continue to process events, because | |
| 324 | + // the scripts will likely need to marshall messages across to the main thread, e.g. | |
| 325 | + // if they access Settings or Menu in any of their shutdown code. So: | |
| 326 | + // Process events for the main application thread, allowing invokeMethod calls to pass between threads. | |
| 327 | + QCoreApplication::processEvents(); | |
| 328 | + // In some cases (debugging), processEvents may give the thread enough time to shut down, so recheck it. | |
| 329 | + if (!thread()) { | |
| 330 | + break; | |
| 331 | + } | |
| 332 | + | |
| 329 | 333 | // Avoid a pure busy wait |
| 330 | 334 | QThread::yieldCurrentThread(); |
| 331 | 335 | } |