Cleanup: Remove unnecessary asset system functions

These functions appear to be thin wrappers around the C++ classes
that previously weren't accessible in C code.
This commit is contained in:
Hans Goudey
2024-02-14 15:09:41 -05:00
parent 7098e53c61
commit 57586df687
8 changed files with 17 additions and 56 deletions

View File

@@ -233,11 +233,6 @@ std::string AS_asset_library_find_suitable_root_path_from_path(blender::StringRe
*/
std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain);
blender::asset_system::AssetCatalogService *AS_asset_library_get_catalog_service(
const blender::asset_system::AssetLibrary *library);
blender::asset_system::AssetCatalogTree *AS_asset_library_get_catalog_tree(
const blender::asset_system::AssetLibrary *library);
/**
* Force clearing of all asset library data. After calling this, new asset libraries can be loaded
* just as usual using #AS_asset_library_load(), no init or other setup is needed.
@@ -256,10 +251,6 @@ void AS_asset_libraries_exit();
blender::asset_system::AssetLibrary *AS_asset_library_load(const char *name,
const char *library_dirpath);
/** Look up the asset's catalog and copy its simple name into #asset_data. */
void AS_asset_library_refresh_catalog_simplename(
blender::asset_system::AssetLibrary *asset_library, AssetMetaData *asset_data);
/** Return whether any loaded AssetLibrary has unsaved changes to its catalogs. */
bool AS_asset_library_has_any_unsaved_catalogs(void);

View File

@@ -94,29 +94,6 @@ std::string AS_asset_library_find_suitable_root_path_from_main(const Main *bmain
return AS_asset_library_find_suitable_root_path_from_path(bmain->filepath);
}
AssetCatalogService *AS_asset_library_get_catalog_service(const AssetLibrary *library)
{
if (library == nullptr) {
return nullptr;
}
return library->catalog_service.get();
}
AssetCatalogTree *AS_asset_library_get_catalog_tree(const AssetLibrary *library)
{
AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(library);
if (catalog_service == nullptr) {
return nullptr;
}
return catalog_service->get_catalog_tree();
}
void AS_asset_library_refresh_catalog_simplename(AssetLibrary *asset_library,
AssetMetaData *asset_data)
{
asset_library->refresh_catalog_simplename(asset_data);
}
void AS_asset_library_remap_ids(const bke::id::IDRemapper &mappings)
{

View File

@@ -15,7 +15,7 @@ OnDiskAssetLibrary::OnDiskAssetLibrary(eAssetLibraryType library_type,
StringRef root_path)
: AssetLibrary(library_type, name, root_path)
{
on_blend_save_handler_register();
this->on_blend_save_handler_register();
}
void OnDiskAssetLibrary::refresh_catalogs()

View File

@@ -12,7 +12,7 @@ namespace blender::asset_system {
RuntimeAssetLibrary::RuntimeAssetLibrary() : AssetLibrary(ASSET_LIBRARY_LOCAL)
{
on_blend_save_handler_register();
this->on_blend_save_handler_register();
}
} // namespace blender::asset_system

View File

@@ -28,8 +28,7 @@ using namespace blender::asset_system;
bool catalogs_read_only(const AssetLibrary &library)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
&library);
asset_system::AssetCatalogService *catalog_service = library.catalog_service.get();
return catalog_service->is_read_only();
}
@@ -62,12 +61,11 @@ asset_system::AssetCatalog *catalog_add(AssetLibrary *library,
StringRefNull name,
StringRef parent_path)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
asset_system::AssetCatalogService *catalog_service = library->catalog_service.get();
if (!catalog_service) {
return nullptr;
}
if (catalogs_read_only(*library)) {
if (catalog_service->is_read_only()) {
return nullptr;
}
@@ -87,13 +85,12 @@ asset_system::AssetCatalog *catalog_add(AssetLibrary *library,
void catalog_remove(AssetLibrary *library, const CatalogID &catalog_id)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
asset_system::AssetCatalogService *catalog_service = library->catalog_service.get();
if (!catalog_service) {
BLI_assert_unreachable();
return;
}
if (catalogs_read_only(*library)) {
if (catalog_service->is_read_only()) {
return;
}
@@ -107,13 +104,12 @@ void catalog_rename(AssetLibrary *library,
const CatalogID catalog_id,
const StringRefNull new_name)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
asset_system::AssetCatalogService *catalog_service = library->catalog_service.get();
if (!catalog_service) {
BLI_assert_unreachable();
return;
}
if (catalogs_read_only(*library)) {
if (catalog_service->is_read_only()) {
return;
}
@@ -137,13 +133,12 @@ void catalog_move(AssetLibrary *library,
const CatalogID src_catalog_id,
const std::optional<CatalogID> dst_parent_catalog_id)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
asset_system::AssetCatalogService *catalog_service = library->catalog_service.get();
if (!catalog_service) {
BLI_assert_unreachable();
return;
}
if (catalogs_read_only(*library)) {
if (catalog_service->is_read_only()) {
return;
}
@@ -181,13 +176,12 @@ void catalog_move(AssetLibrary *library,
void catalogs_save_from_main_path(AssetLibrary *library, const Main *bmain)
{
asset_system::AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
library);
asset_system::AssetCatalogService *catalog_service = library->catalog_service.get();
if (!catalog_service) {
BLI_assert_unreachable();
return;
}
if (catalogs_read_only(*library)) {
if (catalog_service->is_read_only()) {
return;
}

View File

@@ -587,7 +587,7 @@ static asset_system::AssetCatalogService *get_catalog_service(bContext *C)
}
asset_system::AssetLibrary *asset_lib = ED_fileselect_active_asset_library_get(sfile);
return AS_asset_library_get_catalog_service(asset_lib);
return asset_lib->catalog_service.get();
}
static int asset_catalog_undo_exec(bContext *C, wmOperator * /*op*/)

View File

@@ -182,7 +182,7 @@ AssetCatalogTreeView::AssetCatalogTreeView(asset_system::AssetLibrary *library,
FileAssetSelectParams *params,
SpaceFile &space_file)
: asset_library_(library),
catalog_tree_(AS_asset_library_get_catalog_tree(library)),
catalog_tree_(library->catalog_service->get_catalog_tree()),
params_(params),
space_file_(space_file)
{
@@ -502,8 +502,7 @@ AssetCatalog *AssetCatalogDropTarget::get_drag_catalog(
if (drag.type != WM_DRAG_ASSET_CATALOG) {
return nullptr;
}
const AssetCatalogService *catalog_service = AS_asset_library_get_catalog_service(
&asset_library);
const AssetCatalogService *catalog_service = asset_library.catalog_service.get();
const wmDragAssetCatalog *catalog_drag = WM_drag_get_asset_catalog_data(&drag);
return catalog_service->find_catalog(catalog_drag->drag_catalog_id);

View File

@@ -364,7 +364,7 @@ void rna_AssetMetaData_catalog_id_update(bContext *C, PointerRNA *ptr)
}
AssetMetaData *asset_data = static_cast<AssetMetaData *>(ptr->data);
AS_asset_library_refresh_catalog_simplename(asset_library, asset_data);
asset_library->refresh_catalog_simplename(asset_data);
}
static PointerRNA rna_AssetHandle_file_data_get(PointerRNA *ptr)