mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
Ensure we don't hang if the QML thread doesn't shutdown
This commit is contained in:
parent
67e32cc1f0
commit
a0196f0cde
1 changed files with 26 additions and 3 deletions
|
@ -254,10 +254,33 @@ private:
|
|||
_quit = true;
|
||||
}
|
||||
|
||||
static const uint64_t MAX_SHUTDOWN_WAIT_SECS = 5;
|
||||
void stop() {
|
||||
QMutexLocker lock(&_mutex);
|
||||
post(STOP);
|
||||
_cond.wait(&_mutex);
|
||||
if (_thread.isRunning()) {
|
||||
qDebug() << "Stopping QML render thread " << _thread.currentThreadId();
|
||||
{
|
||||
QMutexLocker lock(&_mutex);
|
||||
post(STOP);
|
||||
}
|
||||
auto start = usecTimestampNow();
|
||||
auto now = usecTimestampNow();
|
||||
bool shutdownClean = false;
|
||||
while (now - start < (MAX_SHUTDOWN_WAIT_SECS * USECS_PER_SECOND)) {
|
||||
QMutexLocker lock(&_mutex);
|
||||
if (_cond.wait(&_mutex, MSECS_PER_SECOND)) {
|
||||
shutdownClean = true;
|
||||
break;
|
||||
}
|
||||
now = usecTimestampNow();
|
||||
}
|
||||
|
||||
if (!shutdownClean) {
|
||||
qWarning() << "Failed to shut down the QML render thread";
|
||||
}
|
||||
|
||||
} else {
|
||||
qDebug() << "QML render thread already completed";
|
||||
}
|
||||
}
|
||||
|
||||
bool allowNewFrame(uint8_t fps) {
|
||||
|
|
Loading…
Reference in a new issue