mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
#2704 keep track of simple types by iden to free later
This commit is contained in:
@@ -74,6 +74,7 @@ class IFC_PARSE_API IfcFile {
|
||||
public:
|
||||
typedef std::map<const IfcParse::declaration*, aggregate_of_instance::ptr> entities_by_type_t;
|
||||
typedef boost::unordered_map<unsigned int, IfcUtil::IfcBaseClass*> entity_by_id_t;
|
||||
typedef boost::unordered_map<uint32_t, IfcUtil::IfcBaseClass*> entity_by_iden_t;
|
||||
typedef std::map<std::string, IfcUtil::IfcBaseClass*> entity_by_guid_t;
|
||||
typedef std::tuple<int, int, int> inverse_attr_record;
|
||||
enum INVERSE_ATTR { INSTANCE_ID, INSTANCE_TYPE, ATTRIBUTE_INDEX };
|
||||
@@ -133,6 +134,8 @@ private:
|
||||
std::vector<Argument*> internal_attribute_vector_, internal_attribute_vector_simple_type_;
|
||||
|
||||
entity_by_id_t byid;
|
||||
// this is for simple types
|
||||
entity_by_iden_t byidentity;
|
||||
entities_by_type_t bytype;
|
||||
entities_by_type_t bytype_excl;
|
||||
entities_by_ref_t byref;
|
||||
|
||||
@@ -985,6 +985,7 @@ EntityArgument::~EntityArgument() {
|
||||
// For that purpose when parsed, the simple type instance is explicitly added to the
|
||||
// file. The reason is we want parsed simply types to behave the same as constructed
|
||||
// simple types.
|
||||
|
||||
// delete entity;
|
||||
}
|
||||
|
||||
@@ -1877,8 +1878,13 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
|
||||
// See whether the instance is already part of a file
|
||||
if (entity->data().file != 0) {
|
||||
if (entity->data().file == this) {
|
||||
if (!entity->declaration().as_entity()) {
|
||||
// While not a mapping that can be queried, we do need to free the instance later on
|
||||
byidentity[new_entity->identity()] = new_entity;
|
||||
}
|
||||
|
||||
// If it is part of this file
|
||||
// nothing needs to be done.
|
||||
// nothing else needs to be done.
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -2082,6 +2088,9 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
|
||||
// pointer has to be set, so that actual copies are created in subsequent
|
||||
// times.
|
||||
new_entity->data().file = this;
|
||||
|
||||
// While not a mapping that can be queried, we do need to free the instance
|
||||
byidentity[new_entity->identity()] = new_entity;
|
||||
}
|
||||
|
||||
if (parsing_complete_ && ty->as_entity()) {
|
||||
@@ -2371,7 +2380,7 @@ IfcFile::~IfcFile() {
|
||||
for (const auto& pair : byid) {
|
||||
entities_to_delete.insert(pair.second);
|
||||
}
|
||||
for (const auto& pair : entity_file_map) {
|
||||
for (const auto& pair : byidentity) {
|
||||
entities_to_delete.insert(pair.second);
|
||||
}
|
||||
for (auto entity : entities_to_delete) {
|
||||
|
||||
Reference in New Issue
Block a user