PyAPI: Allow prop collection raw array read access for non-editable props #114063

Merged
Bastien Montagne merged 4 commits from Mysteryem/blender:prop_collection_raw_read_access into main 2023-11-06 15:51:16 +01:00
2 changed files with 4 additions and 2 deletions
Showing only changes of commit 886d92bcb1 - Show all commits

View File

@ -454,6 +454,7 @@ bool RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, Pointe
int RNA_property_collection_raw_array(PointerRNA *ptr,
PropertyRNA *prop,

Would rather use bool when adding new boolean parameters. usage of int for these is only for historical reasons, and (still) needs to be cleaned up...

Would rather use `bool` when adding new boolean parameters. usage of `int` for these is only for historical reasons, and (still) needs to be cleaned up...
PropertyRNA *itemprop,
int set,
RawArray *array);
int RNA_property_collection_raw_get(struct ReportList *reports,
PointerRNA *ptr,

View File

@ -4408,6 +4408,7 @@ bool RNA_property_collection_type_get(PointerRNA *ptr, PropertyRNA *prop, Pointe
int RNA_property_collection_raw_array(PointerRNA *ptr,
PropertyRNA *prop,
PropertyRNA *itemprop,
int set,
RawArray *array)
{
CollectionPropertyIterator iter;
@ -4429,7 +4430,7 @@ int RNA_property_collection_raw_array(PointerRNA *ptr,
internal = &iter.internal.array;
arrayp = (iter.valid) ? static_cast<char *>(iter.ptr.data) : nullptr;
if (internal->skip || !RNA_property_editable(&iter.ptr, itemprop)) {
if (internal->skip || (set && !RNA_property_editable(&iter.ptr, itemprop))) {
/* we might skip some items, so it's not a proper array */
RNA_property_collection_end(&iter);
return 0;
@ -4587,7 +4588,7 @@ static int rna_raw_access(ReportList *reports,
itemprop = nullptr;
}
/* try to access as raw array */
else if (RNA_property_collection_raw_array(ptr, prop, itemprop, &out)) {
else if (RNA_property_collection_raw_array(ptr, prop, itemprop, set, &out)) {
int arraylen = (itemlen == 0) ? 1 : itemlen;
if (in.len != arraylen * out.len) {
BKE_reportf(reports,