diff --git a/simgear/debug/ErrorReportingCallback.cxx b/simgear/debug/ErrorReportingCallback.cxx index 2cea927f..d735a149 100644 --- a/simgear/debug/ErrorReportingCallback.cxx +++ b/simgear/debug/ErrorReportingCallback.cxx @@ -87,6 +87,11 @@ ErrorReportContext::ErrorReportContext(const std::string& key, const std::string } ErrorReportContext::ErrorReportContext(const ContextMap& context) +{ + addFromMap(context); +} + +void ErrorReportContext::addFromMap(const ContextMap& context) { if (static_contextCallback) { for (const auto& p : context) { @@ -96,6 +101,7 @@ ErrorReportContext::ErrorReportContext(const ContextMap& context) } } + ErrorReportContext::~ErrorReportContext() { if (static_contextCallback) { diff --git a/simgear/debug/ErrorReportingCallback.hxx b/simgear/debug/ErrorReportingCallback.hxx index 6866029e..c4885ff3 100644 --- a/simgear/debug/ErrorReportingCallback.hxx +++ b/simgear/debug/ErrorReportingCallback.hxx @@ -78,7 +78,12 @@ public: /** Allow establishing multiple context values in a single operation */ - ErrorReportContext(const ContextMap& context); + ErrorReportContext(const ContextMap& context = {}); + + /** + @brief allowed delayed add of values + */ + void addFromMap(const ContextMap& context); ~ErrorReportContext(); diff --git a/simgear/scene/model/modellib.cxx b/simgear/scene/model/modellib.cxx index ad0e07b9..9511f83c 100644 --- a/simgear/scene/model/modellib.cxx +++ b/simgear/scene/model/modellib.cxx @@ -143,7 +143,10 @@ SGModelLib::loadModel(const string &path, // establish the error report context so we can attribute any load // errors correctly - simgear::ErrorReportContext ec(data->getErrorContext()); + simgear::ErrorReportContext ec; + if (data) { + ec.addFromMap(data->getErrorContext()); + } if (load2DPanels) { opt->setLoadPanel(static_panelFunc); @@ -164,9 +167,10 @@ SGModelLib::loadDeferredModel(const string &path, SGPropertyNode *prop_root, proxyNode->setLoadingExternalReferenceMode(osg::ProxyNode::DEFER_LOADING_TO_DATABASE_PAGER); proxyNode->setFileName(0, path); - // establish the error report context so we can attribute any load - // errors correctly - simgear::ErrorReportContext ec(data->getErrorContext()); + simgear::ErrorReportContext ec; + if (data) { + ec.addFromMap(data->getErrorContext()); + } osg::ref_ptr opt; opt = SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions()); @@ -199,9 +203,10 @@ SGModelLib::loadPagedModel(SGPropertyNode *prop_root, SGModelData *data, SGModel unsigned int simple_models = 0; osg::PagedLOD *plod = new osg::PagedLOD; - // establish the error report context so we can attribute any load - // errors correctly - simgear::ErrorReportContext ec(data->getErrorContext()); + simgear::ErrorReportContext ec; + if (data) { + ec.addFromMap(data->getErrorContext()); + } osg::ref_ptr opt; opt = SGReaderWriterOptions::copyOrCreate(osgDB::Registry::instance()->getOptions());