Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -855,13 +855,18 @@ void ScriptEngine::run() { · 854 unmodified lines | ||
| 855 | 855 | // We don't want to actually sleep for too long, because it causes our scripts to hang |
| 856 | 856 | // on shutdown and stop... so we want to loop and sleep until we've spent our time in |
| 857 | 857 | // purgatory, constantly checking to see if our script was asked to end |
| 858 | + bool firstTime = true; | |
| 858 | 859 | while (!_isFinished && clock::now() < sleepUntil) { |
| 860 | + if (!firstTime) { | |
| 861 | + QCoreApplication::processEvents(); // before we sleep again, give events a chance to process | |
| 862 | + } | |
| 859 | 863 | auto wouldSleepSlice = (sleepUntil - clock::now()); |
| 860 | 864 | auto thisSleepUntil = sleepUntil; |
| 861 | 865 | if (wouldSleepSlice > FRAME_DURATION) { |
| 862 | 866 | thisSleepUntil = clock::now() + FRAME_DURATION; |
| 863 | 867 | } |
| 864 | 868 | std::this_thread::sleep_until(thisSleepUntil); |
| 869 | + firstTime = false; | |
| 865 | 870 | } |
| 866 | 871 | |
| 867 | 872 | #ifdef SCRIPT_DELAY_DEBUG |