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.
This commit is contained in:
parent
85df7036f7
commit
eb33ee566e
Notes:
blender-bot
2023-02-14 08:10:06 +01:00
Referenced by issue #94895, Crash when opening "wasp_bot[2.8].blend" from 2017
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue