From eed9ac5b6e28ee4986cc639befd5819698407ad8 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 23 Jun 2021 12:07:47 +0200 Subject: Fix Scene/MasterCollection handling in `BKE_main_collection_sync_remap()`. Those were missing proper (explicit) object cache clear, and DEG tagging. Note that this was most likely not an common issue in practice (Collection object cache clearing recursively goes into all parents, so master collection would only miss it in case they had no child collections at all, and tagging of those happens almost always at other steps on remapping). But better to be explicit and consistent here in any case. --- source/blender/blenkernel/intern/layer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 2ac10586fd9..fb9c38f51b7 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -1000,7 +1000,7 @@ void BKE_main_collection_sync_remap(const Main *bmain) /* On remapping of object or collection pointers free caches. */ /* TODO: try to make this faster */ - for (const Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { + for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) { MEM_SAFE_FREE(view_layer->object_bases_array); @@ -1009,6 +1009,10 @@ void BKE_main_collection_sync_remap(const Main *bmain) view_layer->object_bases_hash = NULL; } } + + BKE_collection_object_cache_free(scene->master_collection); + DEG_id_tag_update_ex((Main *)bmain, &scene->master_collection->id, ID_RECALC_COPY_ON_WRITE); + DEG_id_tag_update_ex((Main *)bmain, &scene->id, ID_RECALC_COPY_ON_WRITE); } for (Collection *collection = bmain->collections.first; collection; -- cgit v1.2.3