diff options
author | Julian Eisel <julian@blender.org> | 2021-11-24 20:37:33 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-11-24 20:37:33 +0300 |
commit | 338408772a077089482de4d99c68126f6b931c21 (patch) | |
tree | 20b1733d8005e17a33dd7f6e093edc8ed3521428 /source/blender/editors/asset/intern | |
parent | 499c24ce7530b484b103fa714e94fc72ef6acfc2 (diff) | |
parent | 71c39a9e2ef300a1ca451f1080cf59dda94ef4a4 (diff) |
Merge branch 'blender-v3.0-release'
Diffstat (limited to 'source/blender/editors/asset/intern')
-rw-r--r-- | source/blender/editors/asset/intern/asset_catalog.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/editors/asset/intern/asset_catalog.cc b/source/blender/editors/asset/intern/asset_catalog.cc index 9634665be7b..787593d0a16 100644 --- a/source/blender/editors/asset/intern/asset_catalog.cc +++ b/source/blender/editors/asset/intern/asset_catalog.cc @@ -122,7 +122,7 @@ void ED_asset_catalog_rename(::AssetLibrary *library, void ED_asset_catalog_move(::AssetLibrary *library, const CatalogID src_catalog_id, - const CatalogID dst_parent_catalog_id) + const std::optional<CatalogID> dst_parent_catalog_id) { bke::AssetCatalogService *catalog_service = BKE_asset_library_get_catalog_service(library); if (!catalog_service) { @@ -131,9 +131,24 @@ void ED_asset_catalog_move(::AssetLibrary *library, } AssetCatalog *src_catalog = catalog_service->find_catalog(src_catalog_id); - AssetCatalog *dst_catalog = catalog_service->find_catalog(dst_parent_catalog_id); + if (!src_catalog) { + BLI_assert_unreachable(); + return; + } + AssetCatalog *dst_catalog = dst_parent_catalog_id ? + catalog_service->find_catalog(*dst_parent_catalog_id) : + nullptr; + if (!dst_catalog && dst_parent_catalog_id) { + BLI_assert_unreachable(); + return; + } - const AssetCatalogPath new_path = dst_catalog->path / StringRef(src_catalog->path.name()); + std::string unique_name = catalog_name_ensure_unique( + *catalog_service, src_catalog->path.name(), dst_catalog ? dst_catalog->path.c_str() : ""); + /* If a destination catalog was given, construct the path using that. Otherwise, the path is just + * the name of the catalog to be moved, which means it ends up at the root level. */ + const AssetCatalogPath new_path = dst_catalog ? (dst_catalog->path / unique_name) : + AssetCatalogPath{unique_name}; const AssetCatalogPath clean_new_path = new_path.cleanup(); if (new_path == src_catalog->path || clean_new_path == src_catalog->path) { |