[Bf-blender-cvs] [daebdcace06] blender2.8: Fix conversion from 2.7x groups to new 2.8 collections - hidden layers.
Bastien Montagne
noreply at git.blender.org
Sun Aug 26 15:49:16 CEST 2018
Commit: daebdcace06e2adda63ce998e9a12d43fce40b8d
Author: Bastien Montagne
Date: Fri Aug 24 16:34:15 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBdaebdcace06e2adda63ce998e9a12d43fce40b8d
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.
===================================================================
M source/blender/blenloader/intern/versioning_280.c
===================================================================
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);
More information about the Bf-blender-cvs
mailing list