File tree Expand file tree Collapse file tree
Sofa/framework/Simulation/Common/src/sofa/simulation/common/xml Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,7 +56,26 @@ bool ObjectElement::init()
5656
5757bool ObjectElement::initNode ()
5858{
59- core::objectmodel::BaseContext* ctx = getParent ()->getObject ()->toBaseContext ();
59+ core::objectmodel::BaseContext* ctx { nullptr };
60+ if (auto * parent = getParent ())
61+ {
62+ if (auto * parentObj = parent->getObject ())
63+ {
64+ ctx = parentObj->toBaseContext ();
65+ }
66+ else
67+ {
68+ msg_error (" XML parser" ) << " Cannot access to a valid component from parent element \' "
69+ << parent->getName () << " \' (type:\' " << parent->getAttribute (" type" )
70+ << " \' ) for the object element \' " << this ->getName () << " \' " ;
71+ }
72+ }
73+ else
74+ {
75+ msg_error (" XML parser" ) << " Cannot find a parent for the object element \' " << this ->getName () << " \' " ;
76+ }
77+ if (!ctx)
78+ return false ;
6079
6180 for (AttributeMap::iterator it = attributes.begin (), itend = attributes.end (); it != itend; ++it)
6281 {
You can’t perform that action at this time.
0 commit comments