mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 14:38:08 +02:00
process events also
This commit is contained in:
parent
755989b8ff
commit
22619a66ba
1 changed files with 5 additions and 0 deletions
|
@ -855,13 +855,18 @@ void ScriptEngine::run() {
|
||||||
// We don't want to actually sleep for too long, because it causes our scripts to hang
|
// We don't want to actually sleep for too long, because it causes our scripts to hang
|
||||||
// on shutdown and stop... so we want to loop and sleep until we've spent our time in
|
// on shutdown and stop... so we want to loop and sleep until we've spent our time in
|
||||||
// purgatory, constantly checking to see if our script was asked to end
|
// purgatory, constantly checking to see if our script was asked to end
|
||||||
|
bool firstTime = true;
|
||||||
while (!_isFinished && clock::now() < sleepUntil) {
|
while (!_isFinished && clock::now() < sleepUntil) {
|
||||||
|
if (!firstTime) {
|
||||||
|
QCoreApplication::processEvents(); // before we sleep again, give events a chance to process
|
||||||
|
}
|
||||||
auto wouldSleepSlice = (sleepUntil - clock::now());
|
auto wouldSleepSlice = (sleepUntil - clock::now());
|
||||||
auto thisSleepUntil = sleepUntil;
|
auto thisSleepUntil = sleepUntil;
|
||||||
if (wouldSleepSlice > FRAME_DURATION) {
|
if (wouldSleepSlice > FRAME_DURATION) {
|
||||||
thisSleepUntil = clock::now() + FRAME_DURATION;
|
thisSleepUntil = clock::now() + FRAME_DURATION;
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_until(thisSleepUntil);
|
std::this_thread::sleep_until(thisSleepUntil);
|
||||||
|
firstTime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SCRIPT_DELAY_DEBUG
|
#ifdef SCRIPT_DELAY_DEBUG
|
||||||
|
|
Loading…
Reference in a new issue