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
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2022-01-14 17:24:43 +0300
committerBastien Montagne <bastien@blender.org>2022-01-14 19:02:05 +0300
commiteb33ee566e33ec6d4d128e57a8555999adc1bf19 (patch)
treeda1123c59e672f87e7dd346b7ea3cb3ecebf6613 /source
parent85df7036f76b87102466079cc46c2bbfb9b17d9c (diff)
Fix T: Crash in do-version of older pre-2.80 blender files.
`BKE_layer_collection_sync` was missing a specific handling for one of those pre-master collection cases, NOTE: It is a bit unfortunate to have to do 'do-version' code in BKE... At some point might look into moving this into actual `do_version` file, but this is not fully trivial not critical improvement for now.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/layer.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index c58820b239b..9e3cea40fb8 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1207,11 +1207,22 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
return;
}
- /* In some cases (from older files) we do have a master collection, yet no matching layer. Create
- * the master one here, so that the rest of the code can work as expected. */
if (BLI_listbase_is_empty(&view_layer->layer_collections)) {
+ /* In some cases (from older files) we do have a master collection, yet no matching layer.
+ * Create the master one here, so that the rest of the code can work as expected. */
layer_collection_add(&view_layer->layer_collections, scene->master_collection);
}
+ else if (BLI_listbase_count_at_most(&view_layer->layer_collections, 2) > 1) {
+ /* In some cases (from older files) we do have a master collection, but no matching layer,
+ * instead all the children of the master collection have their layer collections in the
+ * viewlayer's list. This is not a valid situation, add a layer for the master collection and
+ * add all existing first-level layers as children of that new master layer. */
+ ListBase layer_collections = view_layer->layer_collections;
+ BLI_listbase_clear(&view_layer->layer_collections);
+ LayerCollection *master_layer_collection = layer_collection_add(&view_layer->layer_collections,
+ scene->master_collection);
+ master_layer_collection->layer_collections = layer_collections;
+ }
/* Free cache. */
MEM_SAFE_FREE(view_layer->object_bases_array);