Fix race conditions when reading game title.

Fixes #5030.
This commit is contained in:
Unknown W. Brackets committed 2015-12-24 13:18:46 -08:00
1 parent bc9c3ca649
commit e6b5fbb40a
5 files changed
+23 -16

No files matched your search

+8 -4
View File
@@ -208,6 +208,9 @@ bool GameInfo::LoadFromPath(const std::string &gamePath) {
delete fileLoader;
fileLoader = ConstructFileLoader(gamePath);
filePath_ = gamePath;
// This is a fallback title, while we're loading / if unable to load.
title = File::GetFilename(filePath_);
}
return GetFileLoader()->Exists();
@@ -279,6 +282,11 @@ void GameInfo::ParseParamSFO() {
paramSFOLoaded = true;
}
std::string GameInfo::GetTitle() {
lock_guard guard(lock);
return title;
}
static bool ReadFileToString(IFileSystem *fs, const char *filename, std::string *contents, recursive_mutex *mtx) {
PSPFileInfo info = fs->GetFileInfo(filename);
if (!info.exists) {
@@ -331,10 +339,7 @@ public:
std::string filename = gamePath_;
{
lock_guard lock(info_->lock);
info_->path = gamePath_;
info_->fileType = Identify_File(info_->GetFileLoader());
// Fallback title
info_->title = File::GetFilename(info_->path);
}
switch (info_->fileType) {
@@ -403,7 +408,6 @@ handleELF:
// An elf on its own has no usable information, no icons, no nothing.
{
lock_guard lock(info_->lock);
info_->title = File::GetFilename(filename);
info_->id = "ELF000000";
info_->id_version = "ELF000000_1.00";
info_->paramSFOLoaded = true;