Fix T103186: Missing anonymous attribute reference

Creating the `WeakAnonymousAttributeID` doesn't
increase the reference count, but destructing it does.
This commit is contained in:
Hans Goudey 2022-12-14 11:08:35 -06:00
parent f879c20f72
commit eae1be548d
Notes: blender-bot 2023-02-14 05:52:32 +01:00
Referenced by issue #103186, Crash with Geometry Nodes
1 changed files with 5 additions and 4 deletions

View File

@ -79,6 +79,7 @@ static void add_new_edges(Mesh &mesh,
}
else {
anonymous_ids.append(bke::WeakAnonymousAttributeID(&id.anonymous_id()));
BKE_anonymous_attribute_id_increment_weak(&id.anonymous_id());
}
}
Vector<bke::AttributeIDRef> local_edge_ids;
@ -98,8 +99,8 @@ static void add_new_edges(Mesh &mesh,
void *array;
};
Vector<NewAttributeData> dst_attributes;
for (const bke::AttributeIDRef &id : local_edge_ids) {
bke::GAttributeReader attribute = attributes.lookup(id);
for (const bke::AttributeIDRef &local_id : local_edge_ids) {
bke::GAttributeReader attribute = attributes.lookup(local_id);
if (!attribute) {
continue;
}
@ -115,8 +116,8 @@ static void add_new_edges(Mesh &mesh,
});
/* Free the original attribute as soon as possible to lower peak memory usage. */
attributes.remove(id);
dst_attributes.append({id, type, new_data});
attributes.remove(local_id);
dst_attributes.append({local_id, type, new_data});
}
int *new_orig_indices = nullptr;