diff --git a/include/gz/sim/components/Model.hh b/include/gz/sim/components/Model.hh
index decd6776ed..524581f6c0 100644
--- a/include/gz/sim/components/Model.hh
+++ b/include/gz/sim/components/Model.hh
@@ -75,10 +75,18 @@ namespace serializers
}
}
- _out << ""
- << ""
- << (skip ? std::string() : modelElem->ToString(""))
- << "";
+ if (!skip)
+ {
+ _out << ""
+ << ""
+ << modelElem->ToString("")
+ << "";
+
+ }
+ else
+ {
+ _out << "";
+ }
return _out;
}
@@ -89,13 +97,18 @@ namespace serializers
public: static std::istream &Deserialize(std::istream &_in,
sdf::Model &_model)
{
- sdf::Root root;
std::string sdf(std::istreambuf_iterator(_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())
{
- gzwarn << "Unable to deserialize sdf::Model" << std::endl;
+ gzwarn << "Unable to deserialize sdf::Model " << sdf<< std::endl;
return _in;
}