mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-10 12:21:39 +00:00
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
This commit is contained in:
commit
31d7be521c
21 changed files with 191 additions and 117 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue