mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #10358 from zzmp/fix/minimize-deadlock
Fix deadlock from minimizing
This commit is contained in:
commit
4a8f5e380f
2 changed files with 19 additions and 0 deletions
|
@ -2526,6 +2526,11 @@ bool Application::event(QEvent* event) {
|
|||
|
||||
isPaintingThrottled = false;
|
||||
|
||||
return true;
|
||||
} else if ((int)event->type() == (int)Idle) {
|
||||
float nsecsElapsed = (float)_lastTimeUpdated.nsecsElapsed();
|
||||
idle(nsecsElapsed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6491,10 +6496,22 @@ void Application::activeChanged(Qt::ApplicationState state) {
|
|||
}
|
||||
|
||||
void Application::windowMinimizedChanged(bool minimized) {
|
||||
// initialize the _minimizedWindowTimer
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [&] {
|
||||
connect(&_minimizedWindowTimer, &QTimer::timeout, this, [] {
|
||||
QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(static_cast<QEvent::Type>(Idle)), Qt::HighEventPriority);
|
||||
});
|
||||
});
|
||||
|
||||
// avoid rendering to the display plugin but continue posting Idle events,
|
||||
// so that physics continues to simulate and the deadlock watchdog knows we're alive
|
||||
if (!minimized && !getActiveDisplayPlugin()->isActive()) {
|
||||
_minimizedWindowTimer.stop();
|
||||
getActiveDisplayPlugin()->activate();
|
||||
} else if (minimized && getActiveDisplayPlugin()->isActive()) {
|
||||
getActiveDisplayPlugin()->deactivate();
|
||||
_minimizedWindowTimer.start(THROTTLED_SIM_FRAME_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ public:
|
|||
enum Event {
|
||||
Present = DisplayPlugin::Present,
|
||||
Paint = Present + 1,
|
||||
Idle = Paint + 1,
|
||||
Lambda = Paint + 1
|
||||
};
|
||||
|
||||
|
@ -536,6 +537,7 @@ private:
|
|||
RateCounter<> _avatarSimCounter;
|
||||
RateCounter<> _simCounter;
|
||||
|
||||
QTimer _minimizedWindowTimer;
|
||||
QElapsedTimer _timerStart;
|
||||
QElapsedTimer _lastTimeUpdated;
|
||||
|
||||
|
|
Loading…
Reference in a new issue