Skip to content

Commit

Permalink
Merge branch 'ign-gazebo6' into jrivero/fix_warn_on_runner
Browse files Browse the repository at this point in the history
  • Loading branch information
j-rivero authored Nov 26, 2024
2 parents 8ba04d5 + 8022579 commit 06b0639
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions include/gz/sim/components/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,18 @@ namespace serializers
}
}

_out << "<?xml version=\"1.0\" ?>"
<< "<sdf version='" << SDF_PROTOCOL_VERSION << "'>"
<< (skip ? std::string() : modelElem->ToString(""))
<< "</sdf>";
if (!skip)
{
_out << "<?xml version=\"1.0\" ?>"
<< "<sdf version='" << SDF_PROTOCOL_VERSION << "'>"
<< modelElem->ToString("")
<< "</sdf>";

}
else
{
_out << "";
}
return _out;
}

Expand All @@ -89,13 +97,19 @@ namespace serializers
public: static std::istream &Deserialize(std::istream &_in,
sdf::Model &_model)
{
sdf::Root root;
std::string sdf(std::istreambuf_iterator<char>(_in), {});
if (sdf.empty())
{
return _in;
}

// Its super expensive to create an SDFElement for some reason
sdf::Root root;
sdf::Errors errors = root.LoadSdfString(sdf);
if (!root.Model())
{
ignwarn << "Unable to deserialize sdf::Model" << std::endl;
ignwarn << "Unable to deserialize sdf::Model: " << sdf
<< std::endl;
return _in;
}

Expand Down

0 comments on commit 06b0639

Please sign in to comment.