diff --git a/source/blender/makesrna/intern/rna_access.cc b/source/blender/makesrna/intern/rna_access.cc index c4e1bd8e050..06b1be0842b 100644 --- a/source/blender/makesrna/intern/rna_access.cc +++ b/source/blender/makesrna/intern/rna_access.cc @@ -4551,7 +4551,7 @@ static int rna_raw_access(ReportList *reports, PropertyRNA *itemprop, *iprop; PropertyType itemtype = PropertyType(0); RawArray in; - int itemlen = 0; + int itemlen = 0, arraylen = 0; /* initialize in array, stride assumed 0 in following code */ in.array = inarray; @@ -4578,7 +4578,8 @@ static int rna_raw_access(ReportList *reports, } /* check item array */ - itemlen = RNA_property_array_length(&itemptr_base, itemprop); + arraylen = RNA_property_array_length(&itemptr_base, itemprop); + itemlen = (arraylen == 0) ? 1 : arraylen; /* dynamic array? need to get length per item */ if (itemprop->getlength) { @@ -4586,12 +4587,11 @@ static int rna_raw_access(ReportList *reports, } /* try to access as raw array */ else if (RNA_property_collection_raw_array(ptr, prop, itemprop, set, &out)) { - int arraylen = (itemlen == 0) ? 1 : itemlen; - if (in.len != arraylen * out.len) { + if (in.len != itemlen * out.len) { BKE_reportf(reports, RPT_ERROR, "Array length mismatch (expected %d, got %d)", - out.len * arraylen, + out.len * itemlen, in.len); return 0; } @@ -4602,7 +4602,7 @@ static int rna_raw_access(ReportList *reports, void *outp = out.array; int a, size; - size = RNA_raw_type_sizeof(out.type) * arraylen; + size = RNA_raw_type_sizeof(out.type) * itemlen; for (a = 0; a < out.len; a++) { if (set) { @@ -4622,7 +4622,7 @@ static int rna_raw_access(ReportList *reports, /* Could also be faster with non-matching types, * for now we just do slower loop. */ } - BLI_assert_msg(itemlen == 0 || itemtype != PROP_ENUM, + BLI_assert_msg(arraylen == 0 || itemtype != PROP_ENUM, "Enum array properties should not exist"); } @@ -4652,7 +4652,8 @@ static int rna_raw_access(ReportList *reports, iprop = RNA_struct_find_property(&itemptr, propname); if (iprop) { - itemlen = rna_property_array_length_all_dimensions(&itemptr, iprop); + arraylen = rna_property_array_length_all_dimensions(&itemptr, iprop); + itemlen = (arraylen == 0) ? 1 : arraylen; itemtype = RNA_property_type(iprop); } else { @@ -4667,7 +4668,7 @@ static int rna_raw_access(ReportList *reports, err = 1; break; } - BLI_assert_msg(itemlen == 0 || itemtype != PROP_ENUM, + BLI_assert_msg(arraylen == 0 || itemtype != PROP_ENUM, "Enum array properties should not exist"); } @@ -4680,7 +4681,7 @@ static int rna_raw_access(ReportList *reports, break; } - if (itemlen == 0) { + if (arraylen == 0) { /* handle conversions */ if (set) { switch (itemtype) {