summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorSilent <zdanio95@gmail.com>2019-10-08 22:46:34 +0200
committerSilent <zdanio95@gmail.com>2019-10-19 23:07:10 +0200
commitcc6ffef4a1d5d643dfb3542adf8bc4b3b4dcaef1 (patch)
treee62ffbeeb216f935a2486687de36627e1b405b08 /Source
parent5e7b95db3b87270cb8607a1981cc08a9a679dc1f (diff)
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinQt/GameList/GameTracker.cpp10
-rw-r--r--Source/Core/DolphinQt/GameList/GameTracker.h3
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