From 6ee283dbae2f8597880882635d94d84eb8461cc3 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 4 May 2018 10:25:57 +0200 Subject: [PATCH] Don't fail on parse errors while resolving inverse attributes --- src/ifcparse/IfcParse.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index d5f50d90f9..860f1398db 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1896,15 +1896,20 @@ IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum ty for(IfcEntityList::it it = all->begin(); it != all->end(); ++it) { bool valid = type == IfcSchema::Type::UNDEFINED || (*it)->is(type); if (valid && attribute_index >= 0) { - Argument* arg = (*it)->entity->getArgument(attribute_index); - if (arg->type() == IfcUtil::Argument_ENTITY_INSTANCE) { - valid = instance == *arg; - } else if (arg->type() == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) { - IfcEntityList::ptr li = *arg; - valid = li->contains(instance); - } else if (arg->type() == IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) { - IfcEntityListList::ptr li = *arg; - valid = li->contains(instance); + try { + Argument* arg = (*it)->entity->getArgument(attribute_index); + if (arg->type() == IfcUtil::Argument_ENTITY_INSTANCE) { + valid = instance == *arg; + } else if (arg->type() == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) { + IfcEntityList::ptr li = *arg; + valid = li->contains(instance); + } else if (arg->type() == IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) { + IfcEntityListList::ptr li = *arg; + valid = li->contains(instance); + } + } catch (IfcException& e) { + valid = false; + Logger::Error(e); } } if (valid) {