From cac31761c026f91e7620f85821857b51da7eac1b Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 9 Mar 2016 12:12:11 -0800 Subject: [PATCH] Safer shutdown code in deadlock thread --- interface/src/Application.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ab1a326698..bf83fdcde9 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -250,6 +250,9 @@ public: _heartbeat = usecTimestampNow(); }); heartbeatTimer->start(HEARTBEAT_UPDATE_INTERVAL_SECS * MSECS_PER_SECOND); + connect(qApp, &QCoreApplication::aboutToQuit, [this] { + _quit = true; + }); } void deadlockDetectionCrash() { @@ -258,7 +261,7 @@ public: } void run() override { - while (!qApp->isAboutToQuit()) { + while (!_quit) { QThread::sleep(HEARTBEAT_UPDATE_INTERVAL_SECS); auto now = usecTimestampNow(); auto lastHeartbeatAge = now - _heartbeat; @@ -269,6 +272,7 @@ public: } static std::atomic _heartbeat; + bool _quit { false }; }; std::atomic DeadlockWatchdogThread::_heartbeat;