Defer deletion so that traversal still works

This commit is contained in:
Thomas Krijnen
2026-01-13 08:45:04 +01:00
parent 2dd002bcd8
commit e4e4f31d20
+5 -3
View File
@@ -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();
}