Skip to content

Commit

Permalink
Add CommandType::BeginRefresh
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CookiePLMonster committed Oct 19, 2019
1 parent 5e7b95d commit cc6ffef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions Source/Core/DolphinQt/GameList/GameTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});

Expand Down Expand Up @@ -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())
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/DolphinQt/GameList/GameTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class GameTracker final : public QFileSystemWatcher
UpdateDirectory,
UpdateFile,
UpdateMetadata,
PurgeCache
PurgeCache,
BeginRefresh,
};

struct Command
Expand Down

0 comments on commit cc6ffef

Please sign in to comment.