Skip to content
Permalink
Browse files
Merge pull request #10993 from shuffle2/gamelist-cache
qt: defer writing gamelist cache until EndRefresh
  • Loading branch information
JosJuice committed Aug 20, 2022
2 parents 498c06b + 7c3cded commit 924a4ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
@@ -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();
}
}
@@ -94,6 +94,7 @@ class GameTracker final : public QFileSystemWatcher
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;
};

0 comments on commit 924a4ee

Please sign in to comment.