summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2018-03-29 21:52:21 +0200
committerJosJuice <josjuice@gmail.com>2018-03-29 21:52:21 +0200
commitff2fe73ec9c705431deeaf5bdff48d777adec0d5 (patch)
tree8d43cabc7bb269ab94238dc7d466adfc243455b0 /Source
parentd3f432946f1a709a4e6f1b8e9b472473b6e0fd22 (diff)
DolphinQt2: Don't show invalid games in game list
Regression from 1f1dae3. This problem doesn't happen in DolphinWX as far as I know, but if you've ran into the problem in DolphinQt2, it will carry over to DolphinWX because of the shared game list cache.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/DolphinQt2/GameList/GameTracker.cpp4
-rw-r--r--Source/Core/UICommon/GameFileCache.cpp9
-rw-r--r--Source/Core/UICommon/GameFileCache.h1
3 files changed, 11 insertions, 3 deletions
diff --git a/Source/Core/DolphinQt2/GameList/GameTracker.cpp b/Source/Core/DolphinQt2/GameList/GameTracker.cpp
index 64fcaf2d32..4e4dfcb57b 100644
--- a/Source/Core/DolphinQt2/GameList/GameTracker.cpp
+++ b/Source/Core/DolphinQt2/GameList/GameTracker.cpp
@@ -173,7 +173,9 @@ void GameTracker::LoadGame(const QString& path)
if (!DiscIO::ShouldHideFromGameList(converted_path))
{
bool cache_changed = false;
- emit GameLoaded(m_cache.AddOrGet(converted_path, &cache_changed, m_title_database));
+ auto game = m_cache.AddOrGet(converted_path, &cache_changed, m_title_database);
+ if (game)
+ emit GameLoaded(std::move(game));
if (cache_changed)
m_cache.Save();
}
diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp
index a0e1253c18..c25254ee15 100644
--- a/Source/Core/UICommon/GameFileCache.cpp
+++ b/Source/Core/UICommon/GameFileCache.cpp
@@ -28,7 +28,7 @@
namespace UICommon
{
-static constexpr u32 CACHE_REVISION = 7; // Last changed in PR 6281
+static constexpr u32 CACHE_REVISION = 8; // Last changed in PR 6560
std::vector<std::string> FindAllGamePaths(const std::vector<std::string>& directories_to_scan,
bool recursive_scan)
@@ -60,7 +60,12 @@ std::shared_ptr<const GameFile> GameFileCache::AddOrGet(const std::string& path,
[&path](const std::shared_ptr<GameFile>& file) { return file->GetFilePath() == path; });
const bool found = it != m_cached_files.cend();
if (!found)
- m_cached_files.emplace_back(std::make_shared<GameFile>(path));
+ {
+ std::shared_ptr<UICommon::GameFile> game = std::make_shared<GameFile>(path);
+ if (!game->IsValid())
+ return nullptr;
+ m_cached_files.emplace_back(std::move(game));
+ }
std::shared_ptr<GameFile>& result = found ? *it : m_cached_files.back();
if (UpdateAdditionalMetadata(&result, title_database) || !found)
*cache_changed = true;
diff --git a/Source/Core/UICommon/GameFileCache.h b/Source/Core/UICommon/GameFileCache.h
index acfdc3410f..8a13dffc41 100644
--- a/Source/Core/UICommon/GameFileCache.h
+++ b/Source/Core/UICommon/GameFileCache.h
@@ -35,6 +35,7 @@ public:
void Clear();
+ // Returns nullptr if the file is invalid.
std::shared_ptr<const GameFile> AddOrGet(const std::string& path, bool* cache_changed,
const Core::TitleDatabase& title_database);