diff --git a/src/Main/ErrorReporter.cxx b/src/Main/ErrorReporter.cxx index d6f572ef0..9633a063b 100644 --- a/src/Main/ErrorReporter.cxx +++ b/src/Main/ErrorReporter.cxx @@ -82,7 +82,9 @@ string_list static_errorIds = { "error-audio-fx-load", "error-xml-load-command", "error-aircraft-systems", - "error-input-device-config"}; + "error-input-device-config" + "error-ai-traffic-schedule", + "error-airport-data"}; string_list static_errorTypeIds = { "error-type-unknown", @@ -125,7 +127,7 @@ public: _recentLogEntries.push_back(os.str()); while (_recentLogEntries.size() > _preceedingLogMessageCount) { - _recentLogEntries.pop_back(); + _recentLogEntries.pop_front(); } return true; @@ -492,6 +494,10 @@ void ErrorReporter::bind() SGPropertyNode_ptr n = fgGetNode("/sim/error-report", true); d->_enabledNode = n->getNode("enabled", true); + if (!d->_enabledNode->hasValue()) { + d->_enabledNode->setBoolValue(false); // default to off for now + } + d->_displayNode = n->getNode("display", true); d->_activeErrorNode = n->getNode("active", true); } @@ -519,6 +525,14 @@ void ErrorReporter::preinit() void ErrorReporter::init() { + if (!d->_enabledNode) { + SG_LOG(SG_GENERAL, SG_INFO, "Error reporting disabled"); + simgear::setFailureCallback(simgear::FailureCallback()); + simgear::setErrorContextCallback(simgear::ContextCallback()); + sglog().removeCallback(d->_logCallback.get()); + return; + } + globals->get_commands()->addCommand("dismiss-error-report", d.get(), &ErrorReporterPrivate::dismissReportCommand); globals->get_commands()->addCommand("save-error-report-data", d.get(), &ErrorReporterPrivate::saveReportCommand); @@ -535,6 +549,10 @@ void ErrorReporter::update(double dt) { std::lock_guard<std::mutex> g(d->_lock); + if (!d->_enabledNode->getBoolValue()) { + return; + } + SGTimeStamp n = SGTimeStamp::now(); // ensure we pause between successive error dialogs @@ -582,9 +600,11 @@ void ErrorReporter::update(double dt) void ErrorReporter::shutdown() { - globals->get_commands()->removeCommand("dismiss-error-report"); - globals->get_commands()->removeCommand("save-error-report-data"); - sglog().removeCallback(d->_logCallback.get()); + if (d->_enabledNode) { + globals->get_commands()->removeCommand("dismiss-error-report"); + globals->get_commands()->removeCommand("save-error-report-data"); + sglog().removeCallback(d->_logCallback.get()); + } } } // namespace flightgear diff --git a/src/Traffic/TrafficMgr.cxx b/src/Traffic/TrafficMgr.cxx index 14eee33ca..6d7255e15 100644 --- a/src/Traffic/TrafficMgr.cxx +++ b/src/Traffic/TrafficMgr.cxx @@ -53,12 +53,13 @@ #include <algorithm> #include <simgear/compiler.h> -#include <simgear/misc/sg_path.hxx> +#include <simgear/debug/ErrorReportingCallback.hxx> #include <simgear/io/iostreams/sgstream.hxx> #include <simgear/misc/sg_dir.hxx> +#include <simgear/misc/sg_path.hxx> #include <simgear/props/props.hxx> -#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/exception.hxx> +#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/threads/SGThread.hxx> #include <simgear/timing/sg_time.hxx> @@ -379,6 +380,8 @@ private: simgear::Dir trafficDir(path); simgear::PathList d = trafficDir.children(simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT); + simgear::ErrorReportContext("ai-traffic-dir", path.utf8Str()); + for (const auto& p : d) { simgear::Dir d2(p); SG_LOG(SG_AI, SG_DEBUG, "parsing traffic in:" << p); @@ -390,6 +393,8 @@ private: return; } } catch (sg_exception& e) { + simgear::reportFailure(simgear::LoadFailure::BadData, simgear::ErrorCode::AITrafficSchedule, + "XML errors parsinng traffic:" + e.getFormattedMessage(), xml); SG_LOG(SG_AI, SG_WARN, "XML error parsing traffic file:" << xml << "\n\t" << e.getFormattedMessage()); } }