mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Fixed a crash when attempting to use extension-less files in gamelists containing folders.
This commit is contained in:
parent
715c143324
commit
d692e8f9cd
|
@ -38,6 +38,19 @@ namespace GamelistFileParser
|
||||||
bool found {false};
|
bool found {false};
|
||||||
|
|
||||||
while (path_it != pathList.end()) {
|
while (path_it != pathList.end()) {
|
||||||
|
// Workaround for an extremely rare issue that can basically only happen if a dot (.)
|
||||||
|
// has been defined as a valid extension for the system (meaning extension-less files
|
||||||
|
// are loaded), in combination with the "Only show ROMs from gamelist.xml files" option
|
||||||
|
// being enabled and a stale entry being present in the gamelist.xml file that perfectly
|
||||||
|
// matches a folder which is actually in use. The workaround is not a perfect solution
|
||||||
|
// but it at least prevents the application from crashing.
|
||||||
|
if (treeNode->getType() != FOLDER) {
|
||||||
|
LOG(LogWarning)
|
||||||
|
<< "Invalid gamelist entry caused by folder having the same name as a stale "
|
||||||
|
<< "extension-less game file (this may cause undefined behavior):";
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
const std::unordered_map<std::string, FileData*>& children {
|
const std::unordered_map<std::string, FileData*>& children {
|
||||||
treeNode->getChildrenByFilename()};
|
treeNode->getChildrenByFilename()};
|
||||||
|
|
||||||
|
|
|
@ -319,7 +319,8 @@ bool SystemData::populateFolder(FileData* folder)
|
||||||
isGame = false;
|
isGame = false;
|
||||||
|
|
||||||
if (std::find(mEnvData->mSearchExtensions.cbegin(), mEnvData->mSearchExtensions.cend(),
|
if (std::find(mEnvData->mSearchExtensions.cbegin(), mEnvData->mSearchExtensions.cend(),
|
||||||
extension) != mEnvData->mSearchExtensions.cend()) {
|
extension) != mEnvData->mSearchExtensions.cend() &&
|
||||||
|
!(isDirectory && extension == ".")) {
|
||||||
FileData* newGame {new FileData(GAME, filePath, mEnvData, this)};
|
FileData* newGame {new FileData(GAME, filePath, mEnvData, this)};
|
||||||
|
|
||||||
// If adding a configured file extension to a directory it will get interpreted as
|
// If adding a configured file extension to a directory it will get interpreted as
|
||||||
|
@ -327,7 +328,7 @@ bool SystemData::populateFolder(FileData* folder)
|
||||||
// entries or for emulators that can get directories passed to them as command line
|
// entries or for emulators that can get directories passed to them as command line
|
||||||
// parameters instead of regular files. In these instances we remove the extension
|
// parameters instead of regular files. In these instances we remove the extension
|
||||||
// from the metadata name so it does not show up in the gamelists and similar.
|
// from the metadata name so it does not show up in the gamelists and similar.
|
||||||
if (isDirectory) {
|
if (isDirectory && extension != ".") {
|
||||||
const std::string& folderName {newGame->metadata.get("name")};
|
const std::string& folderName {newGame->metadata.get("name")};
|
||||||
newGame->metadata.set(
|
newGame->metadata.set(
|
||||||
"name", folderName.substr(0, folderName.length() - extension.length()));
|
"name", folderName.substr(0, folderName.length() - extension.length()));
|
||||||
|
|
Loading…
Reference in a new issue