summaryrefslogtreecommitdiff
path: root/Source/Core/UICommon/GameFileCache.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2020-11-18 02:14:51 +0100
committerGitHub <noreply@github.com>2020-11-18 02:14:51 +0100
commit31d7be521caeae61eeadc687370817812fe32032 (patch)
treee0e02267db0a29015a816e1479eb5c0054c9b240 /Source/Core/UICommon/GameFileCache.cpp
parent033988980661eebc7e3c3dccfcf7331aa5ed25dd (diff)
parentee13e6ec80f4652274156867d8d44737f80f59ba (diff)
Merge pull request #7714 from cristian64/avoid_leaking_gamelistmodel
DolphinQt: Avoid leaking the GameListModel instance to gracefully shutdown the GameTracker and prevent a crash on exit
Diffstat (limited to 'Source/Core/UICommon/GameFileCache.cpp')
-rw-r--r--Source/Core/UICommon/GameFileCache.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp
index 35d4fe3571..38dd09f8a8 100644
--- a/Source/Core/UICommon/GameFileCache.cpp
+++ b/Source/Core/UICommon/GameFileCache.cpp
@@ -90,7 +90,8 @@ std::shared_ptr<const GameFile> GameFileCache::AddOrGet(const std::string& path,
bool GameFileCache::Update(
const std::vector<std::string>& all_game_paths,
std::function<void(const std::shared_ptr<const GameFile>&)> game_added_to_cache,
- std::function<void(const std::string&)> game_removed_from_cache)
+ std::function<void(const std::string&)> game_removed_from_cache,
+ const std::atomic_bool& processing_halted)
{
// Copy game paths into a set, except ones that match DiscIO::ShouldHideFromGameList.
// TODO: Prevent DoFileSearch from looking inside /files/ directories of DirectoryBlobs at all?
@@ -113,6 +114,9 @@ bool GameFileCache::Update(
auto end = m_cached_files.end();
while (it != end)
{
+ if (processing_halted)
+ break;
+
if (game_paths.erase((*it)->GetFilePath()))
{
++it;
@@ -134,6 +138,9 @@ bool GameFileCache::Update(
// aren't in m_cached_files, so we simply add all of them to m_cached_files.
for (const std::string& path : game_paths)
{
+ if (processing_halted)
+ break;
+
auto file = std::make_shared<GameFile>(path);
if (file->IsValid())
{
@@ -149,12 +156,16 @@ bool GameFileCache::Update(
}
bool GameFileCache::UpdateAdditionalMetadata(
- std::function<void(const std::shared_ptr<const GameFile>&)> game_updated)
+ std::function<void(const std::shared_ptr<const GameFile>&)> game_updated,
+ const std::atomic_bool& processing_halted)
{
bool cache_changed = false;
for (std::shared_ptr<GameFile>& file : m_cached_files)
{
+ if (processing_halted)
+ break;
+
const bool updated = UpdateAdditionalMetadata(&file);
cache_changed |= updated;
if (game_updated && updated)