mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Fix #208
This commit is contained in:
@@ -1383,7 +1383,6 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
throw IfcParse::IfcException("Instance not part of this file");
|
||||
}
|
||||
|
||||
std::set<IfcUtil::IfcBaseClass*> deletion_queue;
|
||||
IfcEntityList::ptr references = entitiesByReference(id);
|
||||
|
||||
// Alter entity instances with INVERSE relations to the entity being
|
||||
@@ -1404,7 +1403,6 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
IfcUtil::IfcBaseClass* instance_attribute = *attr;
|
||||
if (instance_attribute == entity) {
|
||||
make_writable(related_instance)->setArgument(i);
|
||||
// deletion_queue.insert(related_instance);
|
||||
} }
|
||||
break;
|
||||
case IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
|
||||
@@ -1412,9 +1410,6 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
if (instance_list->contains(entity)) {
|
||||
instance_list->remove(entity);
|
||||
make_writable(related_instance)->setArgument(i, instance_list);
|
||||
/* if (instance_list->size() == 0) {
|
||||
deletion_queue.insert(related_instance);
|
||||
} */
|
||||
} }
|
||||
break;
|
||||
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
|
||||
@@ -1430,9 +1425,6 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
new_list->push(instances);
|
||||
}
|
||||
make_writable(related_instance)->setArgument(i, new_list);
|
||||
/* if (new_list->totalSize() == 0) {
|
||||
deletion_queue.insert(related_instance);
|
||||
} */
|
||||
} }
|
||||
break;
|
||||
default: break;
|
||||
@@ -1446,9 +1438,13 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
|
||||
IfcUtil::IfcBaseClass* entity_attribute = *it;
|
||||
if (entity_attribute == entity) continue;
|
||||
entitiesByReference(entity_attribute->entity->id())->remove(entity);
|
||||
if (entitiesByReference(entity_attribute->entity->id())->filtered(weak_roots)->size() == 0) {
|
||||
deletion_queue.insert(entity_attribute);
|
||||
if (entity_attribute->entity->id() != 0) {
|
||||
// Do not update inverses for simple types.
|
||||
const IfcEntityList::ptr attribute_inverses = entitiesByReference(entity_attribute->entity->id());
|
||||
|
||||
if (attribute_inverses) {
|
||||
attribute_inverses->remove(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1462,11 +1458,6 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
|
||||
IfcEntityList::ptr instances_of_same_type = entitiesByType(entity->type());
|
||||
instances_of_same_type->remove(entity);
|
||||
|
||||
while (!deletion_queue.empty()) {
|
||||
removeEntity(*deletion_queue.begin());
|
||||
deletion_queue.erase(deletion_queue.begin());
|
||||
}
|
||||
|
||||
delete entity->entity;
|
||||
delete entity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user