diff --git a/src/App/PropertyContainer.cpp b/src/App/PropertyContainer.cpp index 5fda5ce279..a7438cea2f 100644 --- a/src/App/PropertyContainer.cpp +++ b/src/App/PropertyContainer.cpp @@ -332,21 +332,21 @@ void PropertyContainer::Restore(Base::XMLReader &reader) reader.readElement("Property"); std::string PropName = reader.getAttribute("name"); std::string TypeName = reader.getAttribute("type"); - auto prop = dynamicProps.restore(*this,PropName.c_str(),TypeName.c_str(),reader); - if(!prop) - prop = getPropertyByName(PropName.c_str()); - - decltype(Property::StatusBits) status; - if(reader.hasAttribute("status")) { - status = decltype(status)(reader.getAttributeAsUnsigned("status")); - if(prop) - prop->setStatusValue(status.to_ulong()); - } // NOTE: We must also check the type of the current property because a // subclass of PropertyContainer might change the type of a property but // not its name. In this case we would force to read-in a wrong property // type and the behaviour would be undefined. try { + auto prop = getPropertyByName(PropName.c_str()); + if(!prop) + prop = dynamicProps.restore(*this,PropName.c_str(),TypeName.c_str(),reader); + + decltype(Property::StatusBits) status; + if(reader.hasAttribute("status")) { + status = decltype(status)(reader.getAttributeAsUnsigned("status")); + if(prop) + prop->setStatusValue(status.to_ulong()); + } // name and type match if (prop && strcmp(prop->getTypeId().getName(), TypeName.c_str()) == 0) { if (!prop->testStatus(Property::Transient)