[Bf-blender-cvs] [02b80276b3f] master: Fix issue in previous commit
Jacques Lucke
noreply at git.blender.org
Wed May 19 10:51:51 CEST 2021
Commit: 02b80276b3f20c5b2502d0c4d689f30590350607
Author: Jacques Lucke
Date: Wed May 19 10:51:36 2021 +0200
Branches: master
https://developer.blender.org/rB02b80276b3f20c5b2502d0c4d689f30590350607
Fix issue in previous commit
When `PointerRNA->data` was null, it was interpreted as being
`None` in Python. This caused the materials slots to not show
correctly in the ui.
===================================================================
M source/blender/makesrna/intern/rna_object.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 3126b45cb82..1dc7519258b 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -1257,7 +1257,8 @@ static int rna_Object_rotation_4d_editable(PointerRNA *ptr, int index)
static int rna_MaterialSlot_index(PointerRNA *ptr)
{
- return POINTER_AS_INT(ptr->data);
+ /* There is an offset of one, so that `ptr->data` is not null. */
+ return POINTER_AS_INT(ptr->data) - 1;
}
static int rna_MaterialSlot_material_editable(PointerRNA *ptr, const char **UNUSED(r_info))
@@ -1422,7 +1423,8 @@ static PointerRNA rna_Object_material_slots_get(CollectionPropertyIterator *iter
PointerRNA ptr;
RNA_pointer_create((ID *)iter->internal.count.ptr,
&RNA_MaterialSlot,
- POINTER_FROM_INT(iter->internal.count.item),
+ /* Add one, so that `ptr->data` is not null. */
+ POINTER_FROM_INT(iter->internal.count.item + 1),
&ptr);
return ptr;
}
More information about the Bf-blender-cvs
mailing list