diff --git a/apps/launcher/utils/cellnameloader.cpp b/apps/launcher/utils/cellnameloader.cpp index 57c009046d..d47e923eb2 100644 --- a/apps/launcher/utils/cellnameloader.cpp +++ b/apps/launcher/utils/cellnameloader.cpp @@ -1,37 +1,45 @@ #include "cellnameloader.hpp" +#include #include #include -QSet CellNameLoader::getCellNames(QStringList& contentPaths) +QSet CellNameLoader::getCellNames(const QStringList& contentPaths) { QSet cellNames; ESM::ESMReader esmReader; // Loop through all content files - for (auto& contentPath : contentPaths) + for (const QString& contentPath : contentPaths) { if (contentPath.endsWith(".omwscripts", Qt::CaseInsensitive)) continue; - esmReader.open(Files::pathFromQString(contentPath)); - - // Loop through all records - while (esmReader.hasMoreRecs()) + try { - ESM::NAME recordName = esmReader.getRecName(); - esmReader.getRecHeader(); + esmReader.open(Files::pathFromQString(contentPath)); - if (isCellRecord(recordName)) + // Loop through all records + while (esmReader.hasMoreRecs()) { - QString cellName = getCellName(esmReader); - if (!cellName.isEmpty()) - { - cellNames.insert(cellName); - } - } + ESM::NAME recordName = esmReader.getRecName(); + esmReader.getRecHeader(); - // Stop loading content for this record and continue to the next - esmReader.skipRecord(); + if (isCellRecord(recordName)) + { + QString cellName = getCellName(esmReader); + if (!cellName.isEmpty()) + { + cellNames.insert(cellName); + } + } + + // Stop loading content for this record and continue to the next + esmReader.skipRecord(); + } + } + catch (const std::exception& e) + { + Log(Debug::Error) << "Failed to get cell names from " << contentPath.toStdString() << ": " << e.what(); } } diff --git a/apps/launcher/utils/cellnameloader.hpp b/apps/launcher/utils/cellnameloader.hpp index 24ff187f41..6c7993dc5a 100644 --- a/apps/launcher/utils/cellnameloader.hpp +++ b/apps/launcher/utils/cellnameloader.hpp @@ -25,7 +25,7 @@ public: * @param contentPaths the file paths of each content file to be examined * @return the names of all cells */ - QSet getCellNames(QStringList& contentPaths); + QSet getCellNames(const QStringList& contentPaths); private: /**