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:
authorDalai Felinto <dfelinto@gmail.com>2018-01-19 23:44:11 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-01-19 23:44:11 +0300
commite969ac64137e53c0a375886d5e175f1e6b05073a (patch)
treec779ce2fa7daa00816fc1038c479a8a0d67b3b70 /source/blender/blenkernel/intern/collection.c
parent4dfccf8b7f2dfea787d7155b9c531cf56c1b33ae (diff)
Fix collections names no longer unique when moved around
We were not checking for uniqueness after moving. And in some cases the new siblings of our collection may have conflicting names.
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index d0f89eb46e5..edd29f793ec 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -315,6 +315,15 @@ void BKE_collection_rename(const Scene *scene, SceneCollection *sc, const char *
}
/**
+ * Make sure the collection name is still unique within its siblings.
+ */
+static void collection_name_check(const ID *owner_id, SceneCollection *sc)
+{
+ /* It's a bit of a hack, we simply try to make sure the collection name is valid. */
+ collection_rename(owner_id, sc, sc->name);
+}
+
+/**
* Free (or release) any data used by the master collection (does not free the master collection itself).
* Used only to clear the entire scene or group data since it's not doing re-syncing of the LayerCollection tree
*/
@@ -589,6 +598,9 @@ bool BKE_collection_move_above(const ID *owner_id, SceneCollection *sc_dst, Scen
BKE_layer_collection_resync(owner_id, sc_src_parent);
BKE_layer_collection_resync(owner_id, sc_dst_parent);
+ /* Keep names unique. */
+ collection_name_check(owner_id, sc_src);
+
return true;
}
@@ -628,6 +640,9 @@ bool BKE_collection_move_below(const ID *owner_id, SceneCollection *sc_dst, Scen
BKE_layer_collection_resync(owner_id, sc_src_parent);
BKE_layer_collection_resync(owner_id, sc_dst_parent);
+ /* Keep names unique. */
+ collection_name_check(owner_id, sc_src);
+
return true;
}
@@ -663,6 +678,9 @@ bool BKE_collection_move_into(const ID *owner_id, SceneCollection *sc_dst, Scene
BKE_layer_collection_resync(owner_id, sc_src_parent);
BKE_layer_collection_resync(owner_id, sc_dst);
+ /* Keep names unique. */
+ collection_name_check(owner_id, sc_src);
+
return true;
}