Fix #113011: Leak of Anonymous Attributes #113053
@ -123,19 +123,27 @@ static void clean_unused_attributes(const AnonymousAttributePropagationInfo &pro
|
||||
GeometryComponent &component)
|
||||
{
|
||||
std::optional<MutableAttributeAccessor> attributes = component.attributes_for_write();
|
||||
const Set<AttributeIDRef> all_ids = attributes.has_value() ? attributes->all_ids() :
|
||||
Set<AttributeIDRef>();
|
||||
for (const AttributeIDRef &id : all_ids) {
|
||||
if (!attributes.has_value()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector<std::string> unused_ids;
|
||||
attributes->for_all([&](const AttributeIDRef &id, const AttributeMetaData /*meta_data*/) {
|
||||
if (!id.is_anonymous()) {
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
if (skip.contains(id)) {
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
if (propagation_info.propagate(id.anonymous_id())) {
|
||||
mod_moder marked this conversation as resolved
Outdated
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
attributes->remove(id);
|
||||
unused_ids.append(id.name());
|
||||
return true;
|
||||
});
|
||||
|
||||
for (const std::string &unused_id : unused_ids) {
|
||||
attributes->remove(unused_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
Might need to be careful here, removing an attribute may invalidate data referenced by other
AttributeIDRef
(mainly the name). Better first gather the names of all attributes to remove, store them asstd::string
and then remove them in a second loop.