Fix T97502: Issues/crashes with "color_attributes" AttributeGroup

Property collection functions were not really in sync which could result
in crashes in UI_LISTS.

The reason is that attributes of type color defined on domains other than
Points or Corners are still valid, but should really be skipped for the
special "color_attributes".
`rna_AttributeGroup_color_length` itself was fine here, it skips these,
but the iterator (`rna_AttributeGroup_color_iterator_begin` /
`rna_Attributes_noncolor_layer_skip`) wasnt, so when a UI_LIST
filter_items() would iterate the collection it would actually get
results were it shouldnt.

Now check a suiting domain in `rna_Attributes_noncolor_layer_skip` as
well.

Maniphest Tasks: T97502

Differential Revision: https://developer.blender.org/D14717
This commit is contained in:
Philipp Oeser 2022-04-21 14:30:13 +02:00
parent b9799dfb8a
commit f6d5d01715
Notes: blender-bot 2023-02-14 09:21:21 +01:00
Referenced by issue #97502, color attributes crashes blender when they are not on domain vertex or face corner
1 changed files with 9 additions and 1 deletions

View File

@ -339,9 +339,17 @@ static int rna_Attributes_layer_skip(CollectionPropertyIterator *UNUSED(iter), v
return !(CD_TYPE_AS_MASK(layer->type) & CD_MASK_PROP_ALL);
}
static int rna_Attributes_noncolor_layer_skip(CollectionPropertyIterator *UNUSED(iter), void *data)
static int rna_Attributes_noncolor_layer_skip(CollectionPropertyIterator *iter, void *data)
{
CustomDataLayer *layer = (CustomDataLayer *)data;
/* Check valid domain here, too, keep in line with rna_AttributeGroup_color_length(). */
ID *id = iter->parent.owner_id;
AttributeDomain domain = BKE_id_attribute_domain(id, layer);
if (!ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER)) {
return 1;
}
return !(CD_TYPE_AS_MASK(layer->type) & CD_MASK_COLOR_ALL) || (layer->flag & CD_FLAG_TEMPORARY);
}