[Bf-blender-cvs] [f6d5d017150] master: Fix T97502: Issues/crashes with "color_attributes" AttributeGroup

Philipp Oeser noreply at git.blender.org
Thu Apr 21 16:25:23 CEST 2022


Commit: f6d5d017150c54c1f359f6341d758196584ee9eb
Author: Philipp Oeser
Date:   Thu Apr 21 14:30:13 2022 +0200
Branches: master
https://developer.blender.org/rBf6d5d017150c54c1f359f6341d758196584ee9eb

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

===================================================================

M	source/blender/makesrna/intern/rna_attribute.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c
index 6f3688b66f5..5efbebc9b97 100644
--- a/source/blender/makesrna/intern/rna_attribute.c
+++ b/source/blender/makesrna/intern/rna_attribute.c
@@ -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);
 }



More information about the Bf-blender-cvs mailing list