Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in>2021-12-17 16:01:32 +0300
committerSiddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in>2021-12-17 16:01:32 +0300
commitdbc41b30f88b96f7d8c6e995b17f5930eb55cc77 (patch)
treec6c495328443ea3621e5df2ef483b0e0dd504496 /source/blender/editors/asset/intern/asset_catalog.cc
parent99a2af76d10e05a18987be5d554ada197b1ca086 (diff)
parent7c9e4099854a4fc8eab4db97173c1aacd25f9e08 (diff)
Merge branch 'master' into soc-2021-uv-edge-select-supportsoc-2021-uv-edge-select-support
Diffstat (limited to 'source/blender/editors/asset/intern/asset_catalog.cc')
-rw-r--r--source/blender/editors/asset/intern/asset_catalog.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/source/blender/editors/asset/intern/asset_catalog.cc b/source/blender/editors/asset/intern/asset_catalog.cc
index 9634665be7b..f6c02f86f0a 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) {
@@ -158,7 +173,7 @@ void ED_asset_catalogs_save_from_main_path(::AssetLibrary *library, const Main *
/* Since writing to disk also means loading any on-disk changes, it may be a good idea to store
* an undo step. */
catalog_service->undo_push();
- catalog_service->write_to_disk(bmain->name);
+ catalog_service->write_to_disk(bmain->filepath);
}
void ED_asset_catalogs_set_save_catalogs_when_file_is_saved(const bool should_save)