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:06:49 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-10-21 16:53:16 +0300
commit9a1fce698bc6dd51c66464f9dcccfb89d0432823 (patch)
treebaf16b2137a3f36a4f1ded27de26c507b11bfb02 /source/blender/blenkernel/BKE_asset_catalog.hh
parent090be2775e3d7c0dc3f7956b05c7fb9a72c4bdfc (diff)
Cleanup: rename & restructure `AssetCatalogPathCmp`
Rename `AssetCatalogPathCmp` to `AssetCatalogLessThan`: - it compares more than paths (so no more `Path` in the name), and - performs a less-than operation (so no more `Cmp` in the name). Also restructure its code to make an extra upcoming comparison easier to add. No functional changes.
Diffstat (limited to 'source/blender/blenkernel/BKE_asset_catalog.hh')
-rw-r--r--source/blender/blenkernel/BKE_asset_catalog.hh17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh b/source/blender/blenkernel/BKE_asset_catalog.hh
index f7896e0f51e..ca4517707e3 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/blenkernel/BKE_asset_catalog.hh
@@ -395,6 +395,12 @@ class AssetCatalog {
/* Treat this catalog as deleted. Keeping deleted catalogs around is necessary to support
* merging of on-disk changes with in-memory changes. */
bool is_deleted = false;
+
+ /* Sort this catalog first when there are multiple catalogs with the same catalog path. This
+ * ensures that in a situation where missing catalogs were auto-created, and then
+ * load-and-merged with a file that also has these catalogs, the first one in that file is
+ * always sorted first, regardless of the sort order of its UUID. */
+ bool is_first_loaded = false;
} flags;
/**
@@ -411,20 +417,21 @@ class AssetCatalog {
};
/** Comparator for asset catalogs, ordering by (path, UUID). */
-struct AssetCatalogPathCmp {
+struct AssetCatalogLessThan {
bool operator()(const AssetCatalog *lhs, const AssetCatalog *rhs) const
{
- if (lhs->path == rhs->path) {
- return lhs->catalog_id < rhs->catalog_id;
+ if (lhs->path != rhs->path) {
+ return lhs->path < rhs->path;
}
- return lhs->path < rhs->path;
+
+ return lhs->catalog_id < rhs->catalog_id;
}
};
/**
* 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 *, AssetCatalogPathCmp>;
+using AssetCatalogOrderedSet = std::set<const AssetCatalog *, AssetCatalogLessThan>;
/**
* Filter that can determine whether an asset should be visible or not, based on its catalog ID.