From 4c3aa8b48401a7d792c0b7c522aabb3ca9b08518 Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Fri, 23 Oct 2020 14:47:59 +0100 Subject: [PATCH] Check for missing file in several places MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces a ‘missing tag at line 1’ error with a simpler ‘file not found’ message. Sentry-Id: FLIGHTGEAR-5X --- src/AIModel/submodel.cxx | 5 +++++ src/Cockpit/cockpitDisplayManager.cxx | 5 +++++ src/Instrumentation/instrument_mgr.cxx | 5 +++++ src/Systems/system_mgr.cxx | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/src/AIModel/submodel.cxx b/src/AIModel/submodel.cxx index d0df17275..9f939319b 100644 --- a/src/AIModel/submodel.cxx +++ b/src/AIModel/submodel.cxx @@ -484,6 +484,11 @@ void FGSubmodelMgr::setData(int id, const string& path, bool serviceable, const SGPropertyNode root; SGPath config = globals->resolve_aircraft_path(path); + if (!config.exists()) { + SG_LOG(SG_AI, SG_DEV_ALERT, "missing AI submodels file: " << config); + return; + } + try { SG_LOG(SG_AI, SG_DEBUG, "Submodels: Trying to read AI submodels file: " << config); diff --git a/src/Cockpit/cockpitDisplayManager.cxx b/src/Cockpit/cockpitDisplayManager.cxx index 2bad7accb..a706cb69c 100644 --- a/src/Cockpit/cockpitDisplayManager.cxx +++ b/src/Cockpit/cockpitDisplayManager.cxx @@ -63,6 +63,11 @@ void CockpitDisplayManager::init() } SGPath config = globals->resolve_aircraft_path(path_n->getStringValue()); + if (!config.exists()) { + SG_LOG(SG_COCKPIT, SG_DEV_ALERT, "CockpitDisplaysManager: Missing instrumentation file at:" << config); + return; + } + SG_LOG( SG_COCKPIT, SG_INFO, "Reading cockpit displays from " << config ); try { diff --git a/src/Instrumentation/instrument_mgr.cxx b/src/Instrumentation/instrument_mgr.cxx index ff978e176..dd71a0f76 100644 --- a/src/Instrumentation/instrument_mgr.cxx +++ b/src/Instrumentation/instrument_mgr.cxx @@ -73,6 +73,11 @@ void FGInstrumentMgr::init() } SGPath config = globals->resolve_aircraft_path(path_n->getStringValue()); + if (!config.exists()) { + SG_LOG(SG_COCKPIT, SG_DEV_ALERT, "Missing instrumentation file at:" << config); + return; + } + SG_LOG( SG_COCKPIT, SG_INFO, "Reading instruments from " << config ); try { diff --git a/src/Systems/system_mgr.cxx b/src/Systems/system_mgr.cxx index 27694f992..954137a17 100644 --- a/src/Systems/system_mgr.cxx +++ b/src/Systems/system_mgr.cxx @@ -36,6 +36,10 @@ FGSystemMgr::FGSystemMgr () if (path_n) { SGPath config = globals->resolve_aircraft_path(path_n->getStringValue()); + if (!config.exists()) { + SG_LOG( SG_SYSTEMS, SG_DEV_ALERT, "System model file not found:" << config); + return; + } SG_LOG( SG_SYSTEMS, SG_INFO, "Reading systems from " << config );