From f9113c4be836691ba599aab9b2f43e26333f8133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 18 Oct 2021 12:33:53 +0200 Subject: Assets: add global `bke::AssetLibraryService` class Add `blender::bke::AssetLibraryService` class that acts like a blendfile-scoped singleton. It's allocated upon the first call to `BKE_asset_library_load` and destroyed in the LOAD-PRE handler. The `AssetLibraryService` ensures that edits to asset catalogs are not lost when the asset browser editor closes (or even reloads). Instead, the `AssetLibrary` pointers it owns are kept around as long as the blend file is open. Reviewed By: Severin Maniphest Tasks: T92151 Differential Revision: https://developer.blender.org/D12885 --- source/blender/editors/space_file/filelist.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_file/filelist.c') diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 773a321da5c..fc502b065f3 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -391,7 +391,7 @@ typedef struct FileList { eFileSelectType type; /* The library this list was created for. Stored here so we know when to re-read. */ AssetLibraryReference *asset_library_ref; - struct AssetLibrary *asset_library; + struct AssetLibrary *asset_library; /* Non-owning pointer. */ short flags; @@ -1847,9 +1847,7 @@ void filelist_clear_ex(struct FileList *filelist, } if (do_asset_library && (filelist->asset_library != NULL)) { - /* There is no way to refresh the catalogs stored by the AssetLibrary struct, so instead of - * "clearing" it, the entire struct is freed. It will be reallocated when needed. */ - BKE_asset_library_free(filelist->asset_library); + /* The AssetLibraryService owns the AssetLibrary pointer, so no need for us to free it. */ filelist->asset_library = NULL; } } -- cgit v1.2.3