From cc6ffef4a1d5d643dfb3542adf8bc4b3b4dcaef1 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 8 Oct 2019 22:46:34 +0200 Subject: [PATCH] Add CommandType::BeginRefresh This resolves a race condition when spamming Refresh button, which would often end up with duplicates game entries for the entire duration of the session. --- Source/Core/DolphinQt/GameList/GameTracker.cpp | 10 ++++++---- Source/Core/DolphinQt/GameList/GameTracker.h | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinQt/GameList/GameTracker.cpp b/Source/Core/DolphinQt/GameList/GameTracker.cpp index b4f2d7a159..59006d7ee4 100644 --- a/Source/Core/DolphinQt/GameList/GameTracker.cpp +++ b/Source/Core/DolphinQt/GameList/GameTracker.cpp @@ -79,6 +79,11 @@ GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent) case CommandType::PurgeCache: m_cache.Clear(UICommon::GameFileCache::DeleteOnDisk::Yes); break; + case CommandType::BeginRefresh: + for (auto& file : m_tracked_files.keys()) + emit GameRemoved(file.toStdString()); + m_tracked_files.clear(); + break; } }); @@ -177,10 +182,7 @@ void GameTracker::RemoveDirectory(const QString& dir) void GameTracker::RefreshAll() { - for (auto& file : m_tracked_files.keys()) - emit GameRemoved(file.toStdString()); - - m_tracked_files.clear(); + m_load_thread.EmplaceItem(Command{CommandType::BeginRefresh}); for (const QString& dir : Settings::Instance().GetPaths()) { diff --git a/Source/Core/DolphinQt/GameList/GameTracker.h b/Source/Core/DolphinQt/GameList/GameTracker.h index 79a2678d33..c411854a33 100644 --- a/Source/Core/DolphinQt/GameList/GameTracker.h +++ b/Source/Core/DolphinQt/GameList/GameTracker.h @@ -72,7 +72,8 @@ private: UpdateDirectory, UpdateFile, UpdateMetadata, - PurgeCache + PurgeCache, + BeginRefresh, }; struct Command