Fix #107228: AttributeGroup.new crash when layer cannot be created

A layer cannot be created e.g. when creating a reserved-name attributes
with the wrong domain/type.

Caused by 101d04f41f [which just did not
check if the layer creation was successful].

This should go into 3.6 LTS as well.

Pull Request: https://projects.blender.org/blender/blender/pulls/118378
This commit is contained in:
Philipp Oeser
2024-02-16 15:36:31 +01:00
committed by Philipp Oeser
parent 88ba4dfaa3
commit 745d2e18dc

View File

@@ -399,6 +399,10 @@ static PointerRNA rna_AttributeGroup_new(
CustomDataLayer *layer = BKE_id_attribute_new(
id, name, eCustomDataType(type), AttrDomain(domain), reports);
if (!layer) {
return PointerRNA_NULL;
}
if ((GS(id->name) == ID_ME) && ELEM(layer->type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)) {
Mesh *mesh = (Mesh *)id;
if (!mesh->active_color_attribute) {