mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Warning iterator invalidation in removeEntity
This commit is contained in:
@@ -1764,6 +1764,14 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
|||||||
const unsigned id = entity->data().id();
|
const unsigned id = entity->data().id();
|
||||||
IfcUtil::IfcBaseClass* file_entity = instance_by_id(id);
|
IfcUtil::IfcBaseClass* file_entity = instance_by_id(id);
|
||||||
|
|
||||||
|
// Attention when running removeEntity inside a loop over a list of entities to be removed.
|
||||||
|
// This invalidates the iterator. A workaround is to reverse the loop:
|
||||||
|
// boost::shared_ptr<IfcEntityList> entities = ...;
|
||||||
|
// for (auto it = entities->end() - 1; it >= entities->begin(); --it) {
|
||||||
|
// IfcUtil::IfcBaseClass *const inst = *it;
|
||||||
|
// model->removeEntity(inst);
|
||||||
|
// }
|
||||||
|
|
||||||
// TODO: Create a set of weak relations. Inverse relations that do not dictate an
|
// TODO: Create a set of weak relations. Inverse relations that do not dictate an
|
||||||
// instance to be retained. For example: when deleting an IfcRepresentation, the
|
// instance to be retained. For example: when deleting an IfcRepresentation, the
|
||||||
// individual IfcRepresentationItems can not be deleted if an IfcStyledItem is
|
// individual IfcRepresentationItems can not be deleted if an IfcStyledItem is
|
||||||
|
|||||||
Reference in New Issue
Block a user