diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2021-10-12 18:53:05 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2021-10-12 19:07:58 +0300 |
commit | a6da1884ba9f4d3d37c98b48bc18a8d26dd489fc (patch) | |
tree | 5879311a882714ff4ca5fb45dfc141068509a866 /source/blender/makesrna/intern/rna_asset.c | |
parent | 5e3877e0c8560f27a5cd7b303666b235fb148165 (diff) |
Asset Catalogs: Refresh catalog simple name when assigning catalog ID
When assigning a new catalog ID to an asset, also refresh the "catalog
simple name". This "simple name" is stored on the asset metadata next to
the catalog UUID, to allow some emergency data recovery when the catalog
definition file is somehow lost.
Diffstat (limited to 'source/blender/makesrna/intern/rna_asset.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_asset.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c index 80824df1bc8..979d0882dd5 100644 --- a/source/blender/makesrna/intern/rna_asset.c +++ b/source/blender/makesrna/intern/rna_asset.c @@ -215,6 +215,25 @@ static void rna_AssetMetaData_catalog_id_set(PointerRNA *ptr, const char *value) BKE_asset_metadata_catalog_id_set(asset_data, new_uuid, ""); } +void rna_AssetMetaData_catalog_id_update(struct bContext *C, struct PointerRNA *ptr) +{ + SpaceFile *sfile = CTX_wm_space_file(C); + if (sfile == NULL) { + /* Until there is a proper Asset Service available, it's only possible to get the asset library + * from within the asset browser context. */ + return; + } + + AssetLibrary *asset_library = ED_fileselect_active_asset_library_get(sfile); + if (asset_library == NULL) { + /* The SpaceFile may not be an asset browser but a regular file browser. */ + return; + } + + AssetMetaData *asset_data = ptr->data; + BKE_asset_library_refresh_catalog_simplename(asset_library, asset_data); +} + static PointerRNA rna_AssetHandle_file_data_get(PointerRNA *ptr) { AssetHandle *asset_handle = ptr->data; @@ -356,6 +375,7 @@ static void rna_def_asset_data(BlenderRNA *brna) "rna_AssetMetaData_catalog_id_length", "rna_AssetMetaData_catalog_id_set"); RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, 0, "rna_AssetMetaData_catalog_id_update"); RNA_def_property_ui_text(prop, "Catalog UUID", "Identifier for the asset's catalog, used by Blender to look up the " |