From 07954122fbebf40a1ea6fd85fe6fc771a3fd23f2 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 23 Oct 2017 13:32:57 +0200 Subject: [PATCH] Fix #275 --- src/ifcparse/IfcParse.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 45be9d1219..786340229e 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1726,12 +1726,13 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) { for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) { IfcUtil::IfcBaseClass* entity_attribute = *it; if (entity_attribute == entity) continue; - if (entity_attribute->entity->id() != 0) { - // Do not update inverses for simple types. - const IfcEntityList::ptr attribute_inverses = entitiesByReference(entity_attribute->entity->id()); - - if (attribute_inverses) { - attribute_inverses->remove(entity); + const unsigned int name = entity_attribute->entity->id(); + // Do not update inverses for simple types (which have id()==0 in IfcOpenShell). + if (name != 0) { + entities_by_ref_t::iterator it = byref.find(name); + if (it != byref.end()) { + std::vector& ids = it->second; + std::remove(ids.begin(), ids.end(), name); } } }