From 37fe54d2476d9cf3e74998f533035c68cb30eb3f Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 21 Jan 2021 13:24:18 +0100 Subject: [PATCH] erase enitty mapping upon deletion --- src/ifcparse/IfcParse.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 3ceb4205dc..5d2093faee 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1903,6 +1903,16 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) { break; } } + + // This entity_file_map remains obviously flawed, but until we have proper lookup by value, or another mechanism, + // to prevent duplicate definitions with usage of add() we have to keep it. This might be a good moment to clear it. + for (auto it = entity_file_map.begin(); it != entity_file_map.end();) { + if (it->second == entity) { + it = entity_file_map.erase(it); + } else { + ++it; + } + } delete entity; }