diff options
Diffstat (limited to 'source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc')
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index 2a76d5cd362..98c50bf6fdf 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -340,7 +340,15 @@ void scene_remove_unused_view_layers(const Depsgraph *depsgraph, const IDNode *id_node, Scene *scene_cow) { - const ViewLayer *view_layer_input = get_original_view_layer(depsgraph, id_node); + const ViewLayer *view_layer_input; + /* Indirectly linked scenes means it's not an input scene and not a set scene, and is pulled via + * some driver. Such scenes should not have view layers after copy. */ + if (id_node->linked_state == DEG_ID_LINKED_INDIRECTLY) { + view_layer_input = NULL; + } + else { + view_layer_input = get_original_view_layer(depsgraph, id_node); + } ViewLayer *view_layer_eval = NULL; /* Find evaluated view layer. At the same time we free memory used by * all other of the view layers. */ @@ -349,16 +357,17 @@ void scene_remove_unused_view_layers(const Depsgraph *depsgraph, view_layer_cow != NULL; view_layer_cow = view_layer_next) { view_layer_next = view_layer_cow->next; - if (STREQ(view_layer_input->name, view_layer_cow->name)) { + if (view_layer_input != NULL && STREQ(view_layer_input->name, view_layer_cow->name)) { view_layer_eval = view_layer_cow; } else { BKE_view_layer_free_ex(view_layer_cow, false); } } - BLI_assert(view_layer_eval != NULL); - /* Make evaluated view layer the only one in the evaluated scene. */ - view_layer_eval->prev = view_layer_eval->next = NULL; + /* Make evaluated view layer the only one in the evaluated scene (if it exists). */ + if (view_layer_eval != NULL) { + view_layer_eval->prev = view_layer_eval->next = NULL; + } scene_cow->view_layers.first = view_layer_eval; scene_cow->view_layers.last = view_layer_eval; } @@ -367,6 +376,9 @@ void scene_remove_unused_view_layers(const Depsgraph *depsgraph, * objects. */ void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *view_layer) { + if (view_layer == NULL) { + return; + } ListBase enabled_bases = {NULL, NULL}; LISTBASE_FOREACH_MUTABLE (Base *, base, &view_layer->object_bases) { /* TODO(sergey): Would be cool to optimize this somehow, or make it so @@ -397,6 +409,10 @@ void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, ViewLayer *vie void view_layer_update_orig_base_pointers(const ViewLayer *view_layer_orig, ViewLayer *view_layer_eval) { + if (view_layer_orig == NULL || view_layer_eval == NULL) { + /* Happens when scene is only used for parameters or compositor/sequencer. */ + return; + } Base *base_orig = reinterpret_cast<Base *>(view_layer_orig->object_bases.first); LISTBASE_FOREACH (Base *, base_eval, &view_layer_eval->object_bases) { base_eval->base_orig = base_orig; |