Skip to content

Commit e6ff112

Browse files
committed
Catch errors in entity traversal while adding a new entity. In particular for late bound instances having unset attributes.
1 parent 6c8a60d commit e6ff112

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/ifcparse/IfcParse.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -981,12 +981,14 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
981981

982982
// Obtain all forward references by a depth-first
983983
// traversal and add them to the file.
984-
{ IfcEntityList::ptr entity_attributes = traverse(entity, 1);
985-
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
986-
if (*it != entity) {
987-
entity_file_map.insert(entity_entity_map_t::value_type(*it, addEntity(*it)));
984+
try {
985+
IfcEntityList::ptr entity_attributes = traverse(entity, 1);
986+
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
987+
if (*it != entity) {
988+
entity_file_map.insert(entity_entity_map_t::value_type(*it, addEntity(*it)));
989+
}
988990
}
989-
} }
991+
} catch (...) {}
990992

991993
// See whether the instance is already part of a file
992994
if (entity->entity->file != 0) {
@@ -1109,7 +1111,10 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
11091111
byid[new_id] = entity;
11101112

11111113
// The mapping by reference is updated.
1112-
IfcEntityList::ptr entity_attributes = traverse(entity, 1);
1114+
IfcEntityList::ptr entity_attributes(new IfcEntityList);
1115+
try {
1116+
entity_attributes = traverse(entity, 1);
1117+
} catch (...) {}
11131118
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
11141119
IfcUtil::IfcBaseClass* entity_attribute = *it;
11151120
try {

0 commit comments

Comments
 (0)