1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 17:29:55 +00:00

Catch and log exceptions on loading cell names

Instead of terminating the process.
This commit is contained in:
elsid 2023-03-20 23:57:53 +01:00
parent 5a691380ea
commit d18d860ea2
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
2 changed files with 26 additions and 18 deletions

View file

@ -1,18 +1,21 @@
#include "cellnameloader.hpp" #include "cellnameloader.hpp"
#include <components/debug/debuglog.hpp>
#include <components/esm3/loadcell.hpp> #include <components/esm3/loadcell.hpp>
#include <components/files/qtconversion.hpp> #include <components/files/qtconversion.hpp>
QSet<QString> CellNameLoader::getCellNames(QStringList& contentPaths) QSet<QString> CellNameLoader::getCellNames(const QStringList& contentPaths)
{ {
QSet<QString> cellNames; QSet<QString> cellNames;
ESM::ESMReader esmReader; ESM::ESMReader esmReader;
// Loop through all content files // Loop through all content files
for (auto& contentPath : contentPaths) for (const QString& contentPath : contentPaths)
{ {
if (contentPath.endsWith(".omwscripts", Qt::CaseInsensitive)) if (contentPath.endsWith(".omwscripts", Qt::CaseInsensitive))
continue; continue;
try
{
esmReader.open(Files::pathFromQString(contentPath)); esmReader.open(Files::pathFromQString(contentPath));
// Loop through all records // Loop through all records
@ -34,6 +37,11 @@ QSet<QString> CellNameLoader::getCellNames(QStringList& contentPaths)
esmReader.skipRecord(); esmReader.skipRecord();
} }
} }
catch (const std::exception& e)
{
Log(Debug::Error) << "Failed to get cell names from " << contentPath.toStdString() << ": " << e.what();
}
}
return cellNames; return cellNames;
} }

View file

@ -25,7 +25,7 @@ public:
* @param contentPaths the file paths of each content file to be examined * @param contentPaths the file paths of each content file to be examined
* @return the names of all cells * @return the names of all cells
*/ */
QSet<QString> getCellNames(QStringList& contentPaths); QSet<QString> getCellNames(const QStringList& contentPaths);
private: private:
/** /**