mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 21:26:25 +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;
|
_quit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const uint64_t MAX_SHUTDOWN_WAIT_SECS = 5;
|
||||||
void stop() {
|
void stop() {
|
||||||
QMutexLocker lock(&_mutex);
|
if (_thread.isRunning()) {
|
||||||
post(STOP);
|
qDebug() << "Stopping QML render thread " << _thread.currentThreadId();
|
||||||
_cond.wait(&_mutex);
|
{
|
||||||
|
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) {
|
bool allowNewFrame(uint8_t fps) {
|
||||||
|
|
Loading…
Reference in a new issue