diff options
author | Jacques Lucke <jacques@blender.org> | 2021-05-19 11:51:36 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-05-19 11:51:36 +0300 |
commit | 02b80276b3f20c5b2502d0c4d689f30590350607 (patch) | |
tree | a4c07a2da7c84a39900bd66a4ed361b371d95ba6 | |
parent | 1a81d268a19f2f1402f408ad1dadf92c7a399607 (diff) |
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.
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 6 |
1 files changed, 4 insertions, 2 deletions
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; } |