From e4e4f31d2090da0183df82b2cef8b2d4d1a901a7 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 13 Jan 2026 08:45:04 +0100 Subject: [PATCH] Defer deletion so that traversal still works --- src/ifcparse/IfcParse.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index dc820d8439..aca36af03d 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -2022,6 +2022,7 @@ void IfcFile::removeEntity(const express::Base& entity) { batch_deletion_ids_.push_back(id); } else { process_deletion_(entity); + byid_.erase(entity.id()); } } @@ -2112,9 +2113,6 @@ void IfcFile::process_deletion_(const express::Base& entity) { ++it; } } - - // This now frees the shared_ptr - byid_.erase(entity.id()); } void IfcParse::impl::in_memory_file_storage::process_deletion_inverse(const express::Base& entity) { @@ -2613,6 +2611,10 @@ void IfcParse::IfcFile::unbatch() { for (auto& id : batch_deletion_ids_) { process_deletion_(instance_by_id(id)); } + // keep in memory until all deletions are processed + for (auto& id : batch_deletion_ids_) { + byid_.erase(id); + } batch_mode_ = false; batch_deletion_ids_.clear(); }