History

process events also

Brad Hefta-Gaub committed 10 years ago

Commit 22619a61 parent 755989b1 file · +5 −0Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+5−0
@@ -855,13 +855,18 @@ void ScriptEngine::run() { · 854 unmodified lines
855855 // We don't want to actually sleep for too long, because it causes our scripts to hang
856856 // on shutdown and stop... so we want to loop and sleep until we've spent our time in
857857 // purgatory, constantly checking to see if our script was asked to end
858+ bool firstTime = true;
858859 while (!_isFinished && clock::now() < sleepUntil) {
860+ if (!firstTime) {
861+ QCoreApplication::processEvents(); // before we sleep again, give events a chance to process
862+ }
859863 auto wouldSleepSlice = (sleepUntil - clock::now());
860864 auto thisSleepUntil = sleepUntil;
861865 if (wouldSleepSlice > FRAME_DURATION) {
862866 thisSleepUntil = clock::now() + FRAME_DURATION;
863867 }
864868 std::this_thread::sleep_until(thisSleepUntil);
869+ firstTime = false;
865870 }
866871
867872 #ifdef SCRIPT_DELAY_DEBUG