Change error reporting for -set.xml parsing
Avoid exceptions in the ‘not actually a -set.xml’ case, since this occurs somewhat frequently. Sentry-Id: FLIGHTGEAR-3W
This commit is contained in:
parent
e0df583c14
commit
9de60e5729
2 changed files with 12 additions and 5 deletions
|
@ -54,13 +54,14 @@ QDataStream& operator>>(QDataStream& ds, AircraftItem::LocalizedStrings& ls)
|
|||
return ds;
|
||||
}
|
||||
|
||||
AircraftItem::AircraftItem(QDir dir, QString filePath)
|
||||
bool AircraftItem::initFromFile(QDir dir, QString filePath)
|
||||
{
|
||||
SGPropertyNode root;
|
||||
readProperties(filePath.toStdString(), &root);
|
||||
|
||||
if (!root.hasChild("sim")) {
|
||||
throw sg_io_exception(std::string("Malformed -set.xml file"), filePath.toStdString());
|
||||
qWarning() << "-set.xml has no <sim> element" << filePath;
|
||||
return false;
|
||||
}
|
||||
|
||||
SGPropertyNode_ptr sim = root.getNode("sim");
|
||||
|
@ -69,7 +70,7 @@ AircraftItem::AircraftItem(QDir dir, QString filePath)
|
|||
pathModTime = QFileInfo(path).lastModified();
|
||||
if (sim->getBoolValue("exclude-from-gui", false)) {
|
||||
excluded = true;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
LocalizedStrings ls;
|
||||
|
@ -145,6 +146,8 @@ AircraftItem::AircraftItem(QDir dir, QString filePath)
|
|||
_localized.push_front(ls);
|
||||
readLocalizedStrings(sim);
|
||||
doLocalizeStrings();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AircraftItem::readLocalizedStrings(SGPropertyNode_ptr simNode)
|
||||
|
@ -482,7 +485,11 @@ private:
|
|||
item = m_cachedItems.value(absolutePath);
|
||||
} else {
|
||||
// scan the cached item
|
||||
item = AircraftItemPtr(new AircraftItem(childDir, absolutePath));
|
||||
item = AircraftItemPtr(new AircraftItem);
|
||||
bool ok = item->initFromFile(childDir, absolutePath);
|
||||
if (!ok) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
m_nextCache[absolutePath] = item;
|
||||
|
|
|
@ -41,7 +41,7 @@ struct AircraftItem
|
|||
{
|
||||
AircraftItem() = default;
|
||||
|
||||
AircraftItem(QDir dir, QString filePath);
|
||||
bool initFromFile(QDir dir, QString filePath);
|
||||
|
||||
// the file-name without -set.xml suffix
|
||||
QString baseName() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue