From f3dcf0b5395f314de54aa428308a4444b9628c58 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 28 Jun 2026 13:42:36 +0200 Subject: [PATCH] Attempt at less double counting of inverses #7973 --- src/ifcparse/IfcParse.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 1fb3d2a170..28ada453bd 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -1885,6 +1885,9 @@ void IfcFile::addEntities(aggregate_of_instance::ptr entities) { } IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id) { + const bool copying_from_other_file = + entity->file_ != nullptr && entity->file_ != this; + if (id != -1) { bool id_already_exists = false; try { @@ -2164,7 +2167,7 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id) // @todo verify whether this is still needed. If instances are created directly on the file // with create() (which is a necessity for using rocksdb storage) then it should be sufficient // to register inverses only on attribute updates. - if ((ty->as_entity() != nullptr)) { + if (!copying_from_other_file && (ty->as_entity() != nullptr)) { build_inverses_(new_entity); }