From de0826294c59ba57c0bc3878d8410deee1845cc2 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 29 Apr 2020 12:33:25 +0100 Subject: [PATCH] Aircraft-loading: resolve symlinked dirs earlier. This is to ensure we pass a realpath when validating Nasal / dialogs, to fix: https://sourceforge.net/p/flightgear/codetickets/2057/ --- src/Main/fg_init.cxx | 7 ++++--- src/Main/options.cxx | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 06a87ae48..08f5a4d8d 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -347,6 +347,7 @@ private: virtual VisitResult visit(const SGPath& p) { + SGPath realPath = p.realpath(); // create cache node int i = 0; while (1) { @@ -356,17 +357,17 @@ private: SGPropertyNode *n, *entry = _cache->getChild("aircraft", --i, true); - std::string fileName(p.file()); + std::string fileName(realPath.file()); n = entry->getNode("file", true); n->setStringValue(fileName); n->setAttribute(SGPropertyNode::USERARCHIVE, true); n = entry->getNode("path", true); - n->setStringValue(p.dir()); + n->setStringValue(realPath.dir()); n->setAttribute(SGPropertyNode::USERARCHIVE, true); if (simgear::strutils::iequals(fileName, _searchAircraft)) { - _foundPath = p; + _foundPath = realPath; return VISIT_DONE; } diff --git a/src/Main/options.cxx b/src/Main/options.cxx index c6eba0982..75c46a69c 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2251,7 +2251,8 @@ void Options::initAircraft() if (isOptionSet("aircraft-dir")) { SGPath aircraftDirPath = SGPath::fromUtf8(valueForOption("aircraft-dir")); - globals->append_read_allowed_paths(aircraftDirPath); + SGPath realAircraftPath = aircraftDirPath.realpath(); + globals->append_read_allowed_paths(realAircraftPath); // Set this now, so it's available in FindAndCacheAircraft. Use realpath() // as in FGGlobals::append_aircraft_path(), otherwise fgValidatePath() @@ -2259,7 +2260,7 @@ void Options::initAircraft() // is a symlink (which is not a problem, since it was given as is by the // user---this is very different from a symlink *under* the aircraft dir // or a scenery dir). - fgSetString("/sim/aircraft-dir", aircraftDirPath.realpath().utf8Str()); + fgSetString("/sim/aircraft-dir", realAircraftPath.utf8Str()); } if (isOptionSet("state")) {