Tolerate Aircraft/ prefix in preview paths
Reuqested by Jonathan R, allow Aircraft/<acft-dir>/foo paths to work for preview iamges. SF-ID: https://sourceforge.net/p/flightgear/codetickets/2644/
This commit is contained in:
parent
74dd221e60
commit
06c03a0672
1 changed files with 17 additions and 0 deletions
|
@ -122,11 +122,28 @@ bool AircraftItem::initFromFile(QDir dir, QString filePath)
|
|||
|
||||
if (sim->hasChild("previews")) {
|
||||
SGPropertyNode_ptr previewsNode = sim->getChild("previews");
|
||||
const QString aircraftPrefix = "Aircraft/" + dir.dirName() + "/";
|
||||
|
||||
for (auto previewNode : previewsNode->getChildren("preview")) {
|
||||
// add file path as url
|
||||
QString pathInXml = QString::fromStdString(previewNode->getStringValue("path"));
|
||||
|
||||
// https://sourceforge.net/p/flightgear/codetickets/2644/
|
||||
// allow Aircraft/ prefixed paths in previews; what we're actually doing here
|
||||
// is trimming them back to the style we expect
|
||||
if (pathInXml.startsWith(aircraftPrefix)) {
|
||||
pathInXml = pathInXml.mid(aircraftPrefix.length());
|
||||
}
|
||||
|
||||
QString previewPath = dir.absoluteFilePath(pathInXml);
|
||||
|
||||
if (!QFile::exists(previewPath)) {
|
||||
qWarning() << "Missing local preview file" << previewPath;
|
||||
continue;
|
||||
}
|
||||
|
||||
previews.append(QUrl::fromLocalFile(previewPath));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue