Fix #122217 : Datablock Pointers id_properties_ui().update() crashes

It would crash with no `id_type` specified.

Custom Properties Datablock Pointers were introduced in the UI in
b3c7f3c8a9.

When created via python, we dont enforce a `id_type`, when done via the
UI, this should be set though. However, I think when using `update()`,
the `id_type` is optional, so should be possible to just change the
`description` for example and leave the type untouched.

Code was trying to get the id type from the string passed in (None in
this case) and crashed somewhere along the way of
`pyrna_enum_value_from_id` which such NULL string.

So to resolve, just leave the `id_type` untouched if nothing is
specified here.

Pull Request: https://projects.blender.org/blender/blender/pulls/122306
This commit is contained in:
Philipp Oeser
2024-05-27 14:04:00 +02:00
committed by Philipp Oeser
parent f9e42519ae
commit c7dae7e455

View File

@@ -597,14 +597,16 @@ static bool idprop_ui_data_update_id(IDProperty *idprop, PyObject *args, PyObjec
return false;
}
int id_type_tmp;
if (pyrna_enum_value_from_id(
rna_enum_id_type_items, id_type, &id_type_tmp, "IDPropertyUIManager.update") == -1)
{
return false;
}
if (id_type != nullptr) {
int id_type_tmp;
if (pyrna_enum_value_from_id(
rna_enum_id_type_items, id_type, &id_type_tmp, "IDPropertyUIManager.update") == -1)
{
return false;
}
ui_data.id_type = short(id_type_tmp);
ui_data.id_type = short(id_type_tmp);
}
/* Write back to the property's UI data. */
IDP_ui_data_free_unique_contents(&ui_data_orig->base, IDP_ui_data_type(idprop), &ui_data.base);