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:
authorSybren A. Stüvel <sybren@blender.org>2021-10-21 16:53:12 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-10-21 16:53:16 +0300
commit5ccec8ec6bed3e0eda1cffaae565fdfaccd2a6ac (patch)
treeb6f6523e8a3f9e0a9ab1f20171028b03621f026d /source/blender/blenkernel/BKE_asset_catalog.hh
parent9a1fce698bc6dd51c66464f9dcccfb89d0432823 (diff)
Asset Catalogs: treat first-loaded catalog as main catalog
When there are multiple catalogs with the same path (so different UUIDs all mapped to the same catalog path), treat the first-loaded one as the main catalog for that path, and the rest as aliases. This ensures that the UUID of a catalog (as chosen in the tree UI and thus interacted with by users) is stable, regardless of whether by some coincidence later another catalog with the same UUID is created.
Diffstat (limited to 'source/blender/blenkernel/BKE_asset_catalog.hh')
-rw-r--r--source/blender/blenkernel/BKE_asset_catalog.hh15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh b/source/blender/blenkernel/BKE_asset_catalog.hh
index ca4517707e3..5de74efe2cf 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/blenkernel/BKE_asset_catalog.hh
@@ -108,8 +108,12 @@ class AssetCatalogService {
/** Return catalog with the given ID. Return nullptr if not found. */
AssetCatalog *find_catalog(CatalogID catalog_id) const;
- /** Return first catalog with the given path. Return nullptr if not found. This is not an
- * efficient call as it's just a linear search over the catalogs. */
+ /**
+ * Return first catalog with the given path. Return nullptr if not found. This is not an
+ * efficient call as it's just a linear search over the catalogs.
+ *
+ * If there are multiple catalogs with the same path, return the first-loaded one. If there is
+ * none marked as "first loaded", return the one with the lowest UUID. */
AssetCatalog *find_catalog_by_path(const AssetCatalogPath &path) const;
/**
@@ -416,7 +420,7 @@ class AssetCatalog {
static std::string sensible_simple_name_for_path(const AssetCatalogPath &path);
};
-/** Comparator for asset catalogs, ordering by (path, UUID). */
+/** Comparator for asset catalogs, ordering by (path, first_seen, UUID). */
struct AssetCatalogLessThan {
bool operator()(const AssetCatalog *lhs, const AssetCatalog *rhs) const
{
@@ -424,6 +428,10 @@ struct AssetCatalogLessThan {
return lhs->path < rhs->path;
}
+ if (lhs->flags.is_first_loaded != rhs->flags.is_first_loaded) {
+ return lhs->flags.is_first_loaded;
+ }
+
return lhs->catalog_id < rhs->catalog_id;
}
};
@@ -432,6 +440,7 @@ struct AssetCatalogLessThan {
* Set that stores catalogs ordered by (path, UUID).
* Being a set, duplicates are removed. The catalog's simple name is ignored in this. */
using AssetCatalogOrderedSet = std::set<const AssetCatalog *, AssetCatalogLessThan>;
+using MutableAssetCatalogOrderedSet = std::set<AssetCatalog *, AssetCatalogLessThan>;
/**
* Filter that can determine whether an asset should be visible or not, based on its catalog ID.