From 20155df3f62ce6dbfee1001dc46031d83273f5e3 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 4 Aug 2021 09:53:13 +0100 Subject: [PATCH] Sentry: don't catch cmd-line aircraft init failures Only worry about mis-config which occur when using the launcher, since basically all non-launcher ones look to be user errors. --- src/Main/fg_init.cxx | 18 ++++++++++++++---- src/Main/fg_init.hxx | 9 ++++++++- src/Main/main.cxx | 4 +++- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index f8239b619..17bd57d88 100755 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -197,6 +197,11 @@ public: { _cache = autoSave->getNode("sim/startup/path-cache", true); } + + void setDidUseLauncher(bool didUseLauncher) + { + _didUseLauncher = didUseLauncher; + } /** * @brief haveExplicitAircraft - check if the combination of /sim/aircraft @@ -292,7 +297,10 @@ public: SG_LOG(SG_GENERAL, SG_ALERT, "\tin paths:" << SGPath::join(globals->get_aircraft_paths(), ";")); std::string notFoundMessage; - bool reportToSentry = true; + // don't report failures where the launcher was not used, to Sentry, + // since they are nearly all configuration problems. + bool reportToSentry = _didUseLauncher; + if (globals->get_aircraft_paths().empty()) { notFoundMessage = "The requested aircraft (" + aircraft + ") could not be found. No aircraft paths are configured."; reportToSentry = false; // no need to log these @@ -445,7 +453,8 @@ private: std::string _searchAircraft; SGPath _foundPath; - SGPropertyNode* _cache; + SGPropertyNode* _cache = nullptr; + bool _didUseLauncher = false; }; #ifdef _WIN32 @@ -758,7 +767,7 @@ void fgInitAircraftPaths(bool reinit) } } -int fgInitAircraft(bool reinit) +int fgInitAircraft(bool reinit, bool didUseLauncher) { if (!reinit) { auto r = flightgear::Options::sharedInstance()->initAircraft(); @@ -767,6 +776,7 @@ int fgInitAircraft(bool reinit) } FindAndCacheAircraft f(globals->get_props()); + f.setDidUseLauncher(didUseLauncher); const bool haveExplicit = f.haveExplicitAircraft(); SGSharedPtr pkgRoot(globals->packageRoot()); @@ -1367,7 +1377,7 @@ void fgStartNewReset() fgGetNode("/sim")->removeChild("aircraft-dir"); fgInitAircraftPaths(true); - fgInitAircraft(true); + fgInitAircraft(true, false /* not from launcher */); render = new FGRenderer(composite_viewer); render->setEventHandler(eventHandler); diff --git a/src/Main/fg_init.hxx b/src/Main/fg_init.hxx index 6afccef72..495152366 100644 --- a/src/Main/fg_init.hxx +++ b/src/Main/fg_init.hxx @@ -54,7 +54,14 @@ int fgInitConfig ( int argc, char **argv, bool reinit ); void fgInitAircraftPaths(bool reinit); -int fgInitAircraft(bool reinit); +/** + * @brief + * + * @param reinit : is this a second(+) call of the function, i.e after reset + * @param didUseLauncher : allow adjusting UI feedback if we used the launcher or not + * @return int : an Options result to indicate if we should continue, quit, etc + */ +int fgInitAircraft(bool reinit, bool didUseLauncher); // log various settings / configuration state void fgOutputSettings(); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 4d454c977..68871d5fb 100755 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -711,6 +711,7 @@ int fgMainInit( int argc, char **argv ) return EXIT_SUCCESS; } + bool didUseLauncher = false; #if defined(HAVE_QT) if (showLauncher) { flightgear::addSentryBreadcrumb("starting launcher", "info"); @@ -718,6 +719,7 @@ int fgMainInit( int argc, char **argv ) return EXIT_SUCCESS; } + didUseLauncher = true; flightgear::addSentryBreadcrumb("completed launcher", "info"); } #else @@ -732,7 +734,7 @@ int fgMainInit( int argc, char **argv ) auto errorManager = globals->add_new_subsystem(SGSubsystemMgr::GENERAL); errorManager->preinit(); - configResult = fgInitAircraft(false); + configResult = fgInitAircraft(false, didUseLauncher); if (configResult == flightgear::FG_OPTIONS_ERROR) { return EXIT_FAILURE; } else if ((configResult == flightgear::FG_OPTIONS_EXIT) ||