From c202d3865904903a73a18822613f625a3bee344b Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 14 Jul 2021 10:51:28 -0400 Subject: 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 --- source/blender/makesrna/intern/rna_asset.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source/blender/makesrna/intern/rna_asset.c') diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c index 1af53e95cc9..55f680c736d 100644 --- a/source/blender/makesrna/intern/rna_asset.c +++ b/source/blender/makesrna/intern/rna_asset.c @@ -75,16 +75,10 @@ static void rna_AssetMetaData_tag_remove(AssetMetaData *asset_data, RNA_POINTER_INVALIDATE(tag_ptr); } -static IDProperty *rna_AssetMetaData_idprops(PointerRNA *ptr, bool create) +static IDProperty **rna_AssetMetaData_idprops(PointerRNA *ptr) { AssetMetaData *asset_data = ptr->data; - - if (create && !asset_data->properties) { - IDPropertyTemplate val = {0}; - asset_data->properties = IDP_New(IDP_GROUP, &val, "RNA_AssetMetaData group"); - } - - return asset_data->properties; + return &asset_data->properties; } static void rna_AssetMetaData_description_get(PointerRNA *ptr, char *value) -- cgit v1.2.3