Merge pull request #10993 from shuffle2/gamelist-cache

qt: defer writing gamelist cache until EndRefresh
This commit is contained in:
JosJuice 2022-08-20 10:02:12 +02:00 committed by GitHub
commit 924a4ee0be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -89,12 +89,15 @@ GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent)
m_cache.Clear(UICommon::GameFileCache::DeleteOnDisk::Yes);
break;
case CommandType::BeginRefresh:
m_refresh_in_progress = true;
QueueOnObject(this, [] { Settings::Instance().NotifyRefreshGameListStarted(); });
for (auto& file : m_tracked_files.keys())
emit GameRemoved(file.toStdString());
m_tracked_files.clear();
break;
case CommandType::EndRefresh:
m_refresh_in_progress = false;
m_cache.Save();
QueueOnObject(this, [] { Settings::Instance().NotifyRefreshGameListComplete(); });
break;
}
@ -356,7 +359,7 @@ void GameTracker::LoadGame(const QString& path)
auto game = m_cache.AddOrGet(converted_path, &cache_changed);
if (game)
emit GameLoaded(std::move(game));
if (cache_changed)
if (cache_changed && !m_refresh_in_progress)
m_cache.Save();
}
}

View File

@ -94,6 +94,7 @@ private:
bool m_initial_games_emitted = false;
bool m_started = false;
bool m_needs_purge = false;
bool m_refresh_in_progress = false;
std::atomic_bool m_processing_halted = false;
};