From dc7b92651fb4577d8ca0c0fe545c45a2d058775f Mon Sep 17 00:00:00 2001 From: Christian Aguilera Date: Sun, 16 Aug 2020 01:38:28 +0100 Subject: [PATCH] Ensured that GameTracker's internal worker thread is flushed on exit to avoid crashes when accessing stale, already-destroyed data, and to favor responsiveness. --- Source/Core/DolphinQt/GameList/GameTracker.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/GameList/GameTracker.cpp b/Source/Core/DolphinQt/GameList/GameTracker.cpp index 3055ad3170..12f176afbb 100644 --- a/Source/Core/DolphinQt/GameList/GameTracker.cpp +++ b/Source/Core/DolphinQt/GameList/GameTracker.cpp @@ -4,6 +4,7 @@ #include "DolphinQt/GameList/GameTracker.h" +#include #include #include #include @@ -35,6 +36,7 @@ GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent) qRegisterMetaType>(); qRegisterMetaType(); + connect(qApp, &QApplication::aboutToQuit, this, [this] { m_load_thread.Cancel(); }); connect(this, &QFileSystemWatcher::directoryChanged, this, &GameTracker::UpdateDirectory); connect(this, &QFileSystemWatcher::fileChanged, this, &GameTracker::UpdateFile); connect(&Settings::Instance(), &Settings::AutoRefreshToggled, this, [] { @@ -255,7 +257,7 @@ void GameTracker::RemoveDirectoryInternal(const QString& dir) void GameTracker::UpdateDirectoryInternal(const QString& dir) { auto it = GetIterator(dir); - while (it->hasNext()) + while (it->hasNext() && !m_load_thread.IsCancelled()) { QString path = QFileInfo(it->next()).canonicalFilePath();