diff --git a/src/qt_gui/game_info.cpp b/src/qt_gui/game_info.cpp index 60a513d11..1e09ca5c4 100644 --- a/src/qt_gui/game_info.cpp +++ b/src/qt_gui/game_info.cpp @@ -7,7 +7,15 @@ #include "compatibility_info.h" #include "game_info.h" -void ScanDirectoryRecursively(const QString& dir, QStringList& filePaths) { +// Maximum depth to search for games in subdirectories +const int max_recursion_depth = 5; + +void ScanDirectoryRecursively(const QString& dir, QStringList& filePaths, int current_depth = 0) { + // Stop recursion if we've reached the maximum depth + if (current_depth >= max_recursion_depth) { + return; + } + QDir directory(dir); QFileInfoList entries = directory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); @@ -20,8 +28,8 @@ void ScanDirectoryRecursively(const QString& dir, QStringList& filePaths) { if (QFile::exists(entry.filePath() + "/sce_sys/param.sfo")) { filePaths.append(entry.absoluteFilePath()); } else { - // If not a game directory, recursively scan it - ScanDirectoryRecursively(entry.absoluteFilePath(), filePaths); + // If not a game directory, recursively scan it with increased depth + ScanDirectoryRecursively(entry.absoluteFilePath(), filePaths, current_depth + 1); } } } @@ -34,7 +42,7 @@ void GameInfoClass::GetGameInfo(QWidget* parent) { for (const auto& installLoc : Config::getGameInstallDirs()) { QString installDir; Common::FS::PathToQString(installDir, installLoc); - ScanDirectoryRecursively(installDir, filePaths); + ScanDirectoryRecursively(installDir, filePaths, 0); } m_games = QtConcurrent::mapped(filePaths, [&](const QString& path) {