Commit c14d2c41 authored by Martin Heistermann's avatar Martin Heistermann

Do not delete properties that are in-use on clear(); needs more testing

parent 6640cae1
Pipeline #13892 passed with stage
in 5 minutes and 49 seconds
......@@ -91,6 +91,8 @@ public:
virtual size_t size() const = 0;
virtual long use_count() const = 0;
protected:
virtual const std::string &internal_type_name() const = 0;
......
......@@ -142,6 +142,7 @@ public:
void set_handle(const OpenVolumeMeshHandle& _handle) { handle_.idx(_handle.idx()); }
protected:
/// Delete multiple entries in list
......
......@@ -120,6 +120,8 @@ public:
bool anonymous() const override { return ptr::shared_ptr<PropT>::get()->name().empty(); }
virtual long use_count() const override { return ptr::shared_ptr<PropT>::use_count(); }
protected:
const std::string &internal_type_name() const override { return ptr::shared_ptr<PropT>::get()->internal_type_name(); }
......
......@@ -182,14 +182,24 @@ void ResourceManager::entity_deleted(StdVecT& _vec, const OpenVolumeMeshHandle&
}
}
/// delete all properties from given vec that are currently not used,
/// i.e. persistent props with outside references to them.
template<class StdVecT>
void ResourceManager::clearVec(StdVecT& _vec) {
void ResourceManager::clearVec(StdVecT& _vec)
{
StdVecT to_keep;
to_keep.reserve(_vec.size());
for (auto prop: _vec) {
if (prop->use_count() == 1) {
prop->setResMan(nullptr);
delete prop;
} else {
to_keep.push_back(std::move(prop));
}
}
_vec.clear();
_vec = std::move(to_keep);
updatePropHandles(_vec);
}
template<class StdVecT>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment