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.
This commit is contained in:
Silent 2019-10-08 22:46:34 +02:00
parent 5e7b95db3b
commit cc6ffef4a1
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1
2 changed files with 8 additions and 5 deletions

View File

@ -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())
{

View File

@ -72,7 +72,8 @@ private:
UpdateDirectory,
UpdateFile,
UpdateMetadata,
PurgeCache
PurgeCache,
BeginRefresh,
};
struct Command