AIModelData: add error report context
Not complete yet, but add the ability to pass context in from the AIBase to the loader thread. Also add error context to more places in AI / scenario loading.
This commit is contained in:
parent
2178de9d0d
commit
15dfc492dc
3 changed files with 26 additions and 4 deletions
|
@ -32,11 +32,12 @@
|
|||
#include <osg/Node>
|
||||
#include <osgDB/FileUtils>
|
||||
|
||||
#include <simgear/debug/ErrorReportingCallback.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
#include <simgear/scene/model/modellib.hxx>
|
||||
#include <simgear/scene/util/SGNodeMasks.hxx>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/props/props.hxx>
|
||||
|
||||
#include <Main/globals.hxx>
|
||||
#include <Main/fg_props.hxx>
|
||||
|
@ -68,6 +69,16 @@ public:
|
|||
|
||||
FGAIModelData* clone() const override { return new FGAIModelData(); }
|
||||
|
||||
ErrorContext getErrorContext() const override
|
||||
{
|
||||
return _errorContext;
|
||||
}
|
||||
|
||||
void addErrorContext(const std::string& key, std::string& value)
|
||||
{
|
||||
_errorContext[key] = value;
|
||||
}
|
||||
|
||||
/** osg callback, thread-safe */
|
||||
void modelLoaded(const std::string& path, SGPropertyNode *prop, osg::Node *n)
|
||||
{
|
||||
|
@ -120,6 +131,8 @@ private:
|
|||
bool _interiorLoaded = false;
|
||||
float _radius = -1.0;
|
||||
SGPropertyNode* _root;
|
||||
|
||||
ErrorContext _errorContext;
|
||||
};
|
||||
|
||||
FGAIBase::FGAIBase(object_type ot, bool enableHot) :
|
||||
|
@ -307,6 +320,7 @@ void FGAIBase::update(double dt) {
|
|||
const string& fxpath = _modeldata->get_sound_path();
|
||||
if (fxpath != "")
|
||||
{
|
||||
simgear::ErrorReportContext ec("ai-model", _name);
|
||||
props->setStringValue("sim/sound/path", fxpath.c_str());
|
||||
|
||||
// Remove any existing sound FX (e.g. from another model)
|
||||
|
@ -603,6 +617,7 @@ bool FGAIBase::init(ModelSearchOrder searchOrder)
|
|||
|
||||
props->addChild("type")->setStringValue("AI");
|
||||
_modeldata = new FGAIModelData(props);
|
||||
_modeldata->addErrorContext("ai", _name);
|
||||
|
||||
vector<string> model_list = resolveModelPath(searchOrder);
|
||||
_model= SGModelLib::loadPagedModel(model_list, props, _modeldata);
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
Scenario(FGAIManager* man, const std::string& nm, SGPropertyNode* scenarios) :
|
||||
_internalName(nm)
|
||||
{
|
||||
simgear::ErrorReportContext ec("scenario-name", _internalName);
|
||||
for (auto scEntry : scenarios->getChildren("entry")) {
|
||||
FGAIBasePtr ai = man->addObject(scEntry);
|
||||
if (ai) {
|
||||
|
@ -220,7 +221,7 @@ SGPropertyNode_ptr FGAIManager::registerScenarioFile(SGPropertyNode_ptr root, co
|
|||
auto scenariosNode = root->getNode("/sim/ai/scenarios", true);
|
||||
SGPropertyNode_ptr sNode;
|
||||
|
||||
simgear::ErrorReportContext ectx("scenario", xmlPath.utf8Str());
|
||||
simgear::ErrorReportContext ectx("scenario-path", xmlPath.utf8Str());
|
||||
|
||||
// don't report XML errors while loading scenarios, to Sentry
|
||||
flightgear::SentryXMLErrorSupression xml;
|
||||
|
@ -601,7 +602,7 @@ FGAIBasePtr FGAIManager::getObjectFromProperty(const SGPropertyNode* aProp) cons
|
|||
bool
|
||||
FGAIManager::loadScenario( const string &id )
|
||||
{
|
||||
simgear::ErrorReportContext("scenario", id);
|
||||
simgear::ErrorReportContext ec("scenario", id);
|
||||
SGPropertyNode_ptr file = loadScenarioFile(id);
|
||||
if (!file) {
|
||||
return false;
|
||||
|
@ -665,6 +666,7 @@ FGAIManager::loadScenarioFile(const std::string& scenarioName)
|
|||
for (auto n : s->getChildren("scenario")) {
|
||||
if (n->getStringValue("id") == scenarioName) {
|
||||
SGPath path{n->getStringValue("path")};
|
||||
simgear::ErrorReportContext ec("scenario-path", path.utf8Str());
|
||||
try {
|
||||
SGPropertyNode_ptr root = new SGPropertyNode;
|
||||
readProperties(path, root);
|
||||
|
|
|
@ -91,6 +91,11 @@ public:
|
|||
|
||||
virtual FGNasalModelDataProxy* clone() const { return new FGNasalModelDataProxy(_root); }
|
||||
|
||||
ErrorContext getErrorContext() const override
|
||||
{
|
||||
return {}; // return nothing for now, not yet clear if this proxy needs it
|
||||
}
|
||||
|
||||
protected:
|
||||
SGPropertyNode_ptr _root;
|
||||
FGNasalModelDataRef _data;
|
||||
|
|
Loading…
Add table
Reference in a new issue