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:
authorBastien Montagne <montagne29@wanadoo.fr>2018-08-24 17:34:15 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-08-26 16:49:03 +0300
commitdaebdcace06e2adda63ce998e9a12d43fce40b8d (patch)
tree0747e5d7eaf05e8deb2cafb17d947c99fa26a53f
parent56ec606413ef67aead62a04e8e1c7d89be90ece4 (diff)
Fix conversion from 2.7x groups to new 2.8 collections - hidden layers.
You cannot immediately add parent's library to newly generated hidden child collection, since it would allow to get several of those hidden collections with same name/library. That is strictly forbidden! So rather loop again on collections after all hidden ones have been generated, and assign children's library from parent one then.
-rw-r--r--source/blender/blenloader/intern/versioning_280.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index fb579aff479..c101a0dd746 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -564,6 +564,21 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
scene->basact = NULL;
}
+static void do_version_collection_propagate_lib_to_children(Collection *collection)
+{
+ if (collection->id.lib != NULL) {
+ for (CollectionChild *collection_child = collection->children.first;
+ collection_child != NULL;
+ collection_child = collection_child->next)
+ {
+ if (collection_child->collection->id.lib == NULL) {
+ collection_child->collection->id.lib = collection->id.lib;
+ }
+ do_version_collection_propagate_lib_to_children(collection_child->collection);
+ }
+ }
+}
+
void do_versions_after_linking_280(Main *bmain)
{
bool use_collection_compat_28 = true;
@@ -588,7 +603,6 @@ void do_versions_after_linking_280(Main *bmain)
if (!(ob->lay & collection->layer)) {
if (collection_hidden == NULL) {
collection_hidden = BKE_collection_add(bmain, collection, "Hidden");
- collection_hidden->id.lib = collection->id.lib;
collection_hidden->flag |= COLLECTION_RESTRICT_VIEW | COLLECTION_RESTRICT_RENDER;
}
@@ -598,6 +612,13 @@ void do_versions_after_linking_280(Main *bmain)
}
}
+ /* We need to assign lib pointer to generated hidden collections *after* all have been created, otherwise we'll
+ * end up with several datablocks sharing same name/library, which is FORBIDDEN!
+ * Note: we need this to be recursive, since a child collection may be sorted before its parent in bmain... */
+ for (Collection *collection = bmain->collection.first; collection != NULL; collection = collection->id.next) {
+ do_version_collection_propagate_lib_to_children(collection);
+ }
+
/* Convert layers to collections. */
for (Scene *scene = bmain->scene.first; scene; scene = scene->id.next) {
do_version_layers_to_collections(bmain, scene);