From 02b80276b3f20c5b2502d0c4d689f30590350607 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 19 May 2021 10:51:36 +0200 Subject: 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. --- source/blender/makesrna/intern/rna_object.c | 6 ++++-- 1 file 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; } -- cgit v1.2.3