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 | // We don't want to actually sleep for too long, because it causes our scripts to hang | 855 | // We don't want to actually sleep for too long, because it causes our scripts to hang |
| 856 | // on shutdown and stop... so we want to loop and sleep until we've spent our time in | 856 | // on shutdown and stop... so we want to loop and sleep until we've spent our time in |
| 857 | // purgatory, constantly checking to see if our script was asked to end | 857 | // purgatory, constantly checking to see if our script was asked to end |
| 858 | bool firstTime = true; | ||
| 858 | while (!_isFinished && clock::now() < sleepUntil) { | 859 | while (!_isFinished && clock::now() < sleepUntil) { |
| 860 | if (!firstTime) { | ||
| 861 | QCoreApplication::processEvents(); // before we sleep again, give events a chance to process | ||
| 862 | } | ||
| 859 | auto wouldSleepSlice = (sleepUntil - clock::now()); | 863 | auto wouldSleepSlice = (sleepUntil - clock::now()); |
| 860 | auto thisSleepUntil = sleepUntil; | 864 | auto thisSleepUntil = sleepUntil; |
| 861 | if (wouldSleepSlice > FRAME_DURATION) { | 865 | if (wouldSleepSlice > FRAME_DURATION) { |
| 862 | thisSleepUntil = clock::now() + FRAME_DURATION; | 866 | thisSleepUntil = clock::now() + FRAME_DURATION; |
| 863 | } | 867 | } |
| 864 | std::this_thread::sleep_until(thisSleepUntil); | 868 | std::this_thread::sleep_until(thisSleepUntil); |
| 869 | firstTime = false; | ||
| 865 | } | 870 | } |
| 866 | 871 | ||
| 867 | #ifdef SCRIPT_DELAY_DEBUG | 872 | #ifdef SCRIPT_DELAY_DEBUG |