[Bf-blender-cvs] [cebc5531e94] master: Fix T98956: Crash removing some builtin attributes
Hans Goudey
noreply at git.blender.org
Wed Jun 22 16:06:41 CEST 2022
Commit: cebc5531e9445a4f5cc5da85d6c0f0a7dd75fdaa
Author: Hans Goudey
Date: Wed Jun 22 09:06:29 2022 -0500
Branches: master
https://developer.blender.org/rBcebc5531e9445a4f5cc5da85d6c0f0a7dd75fdaa
Fix T98956: Crash removing some builtin attributes
For example, the "id" attribute is stored as a named attribute.
If it doesn't exist already, `layer_index` was uninitialized, causing
issues with `CustomData_free_layer`. The fix is to use the generic
function to free a named layer in that case. Eventually the other
case will go away as T95965 is finished.
===================================================================
M source/blender/blenkernel/intern/attribute_access.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index bc146d87e4c..409941623d2 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -375,27 +375,24 @@ bool BuiltinCustomDataLayerProvider::try_delete(GeometryComponent &component) co
}
const int domain_num = component.attribute_domain_num(domain_);
- int layer_index;
if (stored_as_named_attribute_) {
- for (const int i : IndexRange(custom_data->totlayer)) {
- if (custom_data_layer_matches_attribute_id(custom_data->layers[i], name_)) {
- layer_index = i;
- break;
+ if (CustomData_free_layer_named(custom_data, name_.c_str(), domain_num)) {
+ if (custom_data_access_.update_custom_data_pointers) {
+ custom_data_access_.update_custom_data_pointers(component);
}
+ return true;
}
- }
- else {
- layer_index = CustomData_get_layer_index(custom_data, stored_type_);
+ return false;
}
- const bool delete_success = CustomData_free_layer(
- custom_data, stored_type_, domain_num, layer_index);
- if (delete_success) {
+ const int layer_index = CustomData_get_layer_index(custom_data, stored_type_);
+ if (CustomData_free_layer(custom_data, stored_type_, domain_num, layer_index)) {
if (custom_data_access_.update_custom_data_pointers) {
custom_data_access_.update_custom_data_pointers(component);
}
+ return true;
}
- return delete_success;
+ return false;
}
bool BuiltinCustomDataLayerProvider::try_create(GeometryComponent &component,
More information about the Bf-blender-cvs
mailing list