Fix T87768: `.path_resolve` fails when requested property is None.
Add a version of RNA_path_resolve_full that returns true when the path resolves to a NULL RNA pointer.
This commit is contained in:
parent
0950cfd9d5
commit
f9ccd26b03
Notes:
blender-bot
2023-02-14 10:29:30 +01:00
Referenced by issue #93704, gltf2 not exporting animations in 3.0 Referenced by issue #87768, `.path_resolve` ValueError failure when requested property is None.
|
@ -1124,6 +1124,8 @@ bool RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prop
|
|||
|
||||
bool RNA_path_resolve_full(
|
||||
PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index);
|
||||
bool RNA_path_resolve_full_maybe_null(
|
||||
PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index);
|
||||
|
||||
/* path_resolve_property() variants ensure that pointer + property both exist */
|
||||
bool RNA_path_resolve_property(PointerRNA *ptr,
|
||||
|
|
|
@ -5361,6 +5361,18 @@ bool RNA_path_resolve_full(
|
|||
return r_ptr->data != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* A version of #RNA_path_resolve_full doesn't check the value of #PointerRNA.data.
|
||||
*
|
||||
* \note While it's correct to ignore the value of #PointerRNA.data
|
||||
* most callers need to know if the resulting pointer was found and not null.
|
||||
*/
|
||||
bool RNA_path_resolve_full_maybe_null(
|
||||
PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
|
||||
{
|
||||
return rna_path_parse(ptr, path, r_ptr, r_prop, r_index, NULL, NULL, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given RNA Path to find both the pointer AND property
|
||||
* indicated by fully resolving the path.
|
||||
|
|
|
@ -3663,7 +3663,7 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (RNA_path_resolve_full(&self->ptr, path, &r_ptr, &r_prop, &index)) {
|
||||
if (RNA_path_resolve_full_maybe_null(&self->ptr, path, &r_ptr, &r_prop, &index)) {
|
||||
if (r_prop) {
|
||||
if (index != -1) {
|
||||
if (index >= RNA_property_array_length(&r_ptr, r_prop) || index < 0) {
|
||||
|
|
Loading…
Reference in New Issue