Fix regression when loading project file with unknown object type

This commit is contained in:
wmayer 2012-11-27 16:54:44 +01:00
parent a1bf6277f1
commit a734faae48

View File

@ -746,11 +746,13 @@ Document::readObjects(Base::XMLReader& reader)
// otherwise we may cause a dependency to itself // otherwise we may cause a dependency to itself
// Example: Object 'Cut001' references object 'Cut' and removing the // Example: Object 'Cut001' references object 'Cut' and removing the
// digits we make an object 'Cut' referencing itself. // digits we make an object 'Cut' referencing itself.
App::DocumentObject* o = addObject(type.c_str(),name.c_str()); App::DocumentObject* obj = addObject(type.c_str(),name.c_str());
objs.push_back(o); if (obj) {
objs.push_back(obj);
// use this name for the later access because an object with // use this name for the later access because an object with
// the given name may already exist // the given name may already exist
reader.addName(name.c_str(), o->getNameInDocument()); reader.addName(name.c_str(), obj->getNameInDocument());
}
} }
catch (Base::Exception&) { catch (Base::Exception&) {
Base::Console().Message("Cannot create object '%s'\n", name.c_str()); Base::Console().Message("Cannot create object '%s'\n", name.c_str());