diff options
author | Hans Goudey <h.goudey@me.com> | 2021-07-14 17:51:28 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-07-14 17:51:28 +0300 |
commit | c202d3865904903a73a18822613f625a3bee344b (patch) | |
tree | a5c00dae340b6c3795d238acdd639428e3d28daa /source/blender/makesrna/intern/rna_armature.c | |
parent | 37a5ff4a8470a0040f88228bbf3d439c42389446 (diff) |
Python API: Add functions to ensure and clear IDProperties
This adds id_properties_clear() and id_properties_ensure() functions
to RNA structs. This is meant as an initial change based on discussion
in review of D9697. However, they may be useful in other situations.
The change requires refactoring the internal idproperties callback to
return a pointer to the IDProperty pointer, which actually turns out
to be quite a nice cleanup.
An id_properties attribute could be added in the future potentially.
Differential Revision: https://developer.blender.org/D11908
Diffstat (limited to 'source/blender/makesrna/intern/rna_armature.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_armature.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 7114e21beff..49d02524e43 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -260,28 +260,16 @@ static char *rna_Bone_path(PointerRNA *ptr) return BLI_sprintfN("bones[\"%s\"]", name_esc); } -static IDProperty *rna_Bone_idprops(PointerRNA *ptr, bool create) +static IDProperty **rna_Bone_idprops(PointerRNA *ptr) { Bone *bone = ptr->data; - - if (create && !bone->prop) { - IDPropertyTemplate val = {0}; - bone->prop = IDP_New(IDP_GROUP, &val, "RNA_Bone ID properties"); - } - - return bone->prop; + return &bone->prop; } -static IDProperty *rna_EditBone_idprops(PointerRNA *ptr, bool create) +static IDProperty **rna_EditBone_idprops(PointerRNA *ptr) { EditBone *ebone = ptr->data; - - if (create && !ebone->prop) { - IDPropertyTemplate val = {0}; - ebone->prop = IDP_New(IDP_GROUP, &val, "RNA_EditBone ID properties"); - } - - return ebone->prop; + return &ebone->prop; } static void rna_bone_layer_set(int *layer, const bool *values) |