mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-17 14:43:09 +00:00
Ensure delayed flushes complete during shutdown
This commit is contained in:
parent
5bfe56472f
commit
a13f8e7937
1 changed files with 11 additions and 6 deletions
|
@ -188,6 +188,9 @@ ComputerManager::~ComputerManager()
|
|||
// Wait for it to terminate (and finish any pending flush)
|
||||
m_DelayedFlushThread->wait();
|
||||
delete m_DelayedFlushThread;
|
||||
|
||||
// Delayed flushes should have completed by now
|
||||
Q_ASSERT(!m_NeedsDelayedFlush);
|
||||
}
|
||||
|
||||
QWriteLocker lock(&m_Lock);
|
||||
|
@ -220,7 +223,7 @@ ComputerManager::~ComputerManager()
|
|||
}
|
||||
|
||||
void DelayedFlushThread::run() {
|
||||
while (!QThread::currentThread()->isInterruptionRequested()) {
|
||||
for (;;) {
|
||||
// Wait for a delayed flush request or an interruption
|
||||
{
|
||||
QMutexLocker locker(&m_ComputerManager->m_DelayedFlushMutex);
|
||||
|
@ -229,13 +232,15 @@ void DelayedFlushThread::run() {
|
|||
m_ComputerManager->m_DelayedFlushCondition.wait(&m_ComputerManager->m_DelayedFlushMutex);
|
||||
}
|
||||
|
||||
// Reset the delayed flush flag to ensure any racing saveHosts() call will set it again
|
||||
m_ComputerManager->m_NeedsDelayedFlush = false;
|
||||
// Bail without flushing if we woke up for an interruption alone.
|
||||
// If we have both an interruption and a flush request, do the flush.
|
||||
if (!m_ComputerManager->m_NeedsDelayedFlush) {
|
||||
Q_ASSERT(QThread::currentThread()->isInterruptionRequested());
|
||||
break;
|
||||
}
|
||||
|
||||
if (QThread::currentThread()->isInterruptionRequested()) {
|
||||
// Bail without flushing if we woke up for an interruption
|
||||
break;
|
||||
// Reset the delayed flush flag to ensure any racing saveHosts() call will set it again
|
||||
m_ComputerManager->m_NeedsDelayedFlush = false;
|
||||
}
|
||||
|
||||
// Perform the flush
|
||||
|
|
Loading…
Reference in a new issue