From 339f442a9327d6eeb1bc7a52be702ea9b461df72 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 10 Nov 2020 17:12:36 +0100 Subject: Fix (unreported) potential assert in viewlayer synchronization. Some operations, like remapping and ID (Object) to another, can lead to having the same object in more than one base. While this is not a valid state, this is being taken care of by the `BKE_layer_collection_sync` call, so the object-to-base GHash generation itself should be resilient to such issue. Note: another way to fix this would be to make remapping post-process code check explicitely for such doublons, but I would rather avoid adding even more 'specialized' code there, it already has to deal with too many of those corner cases. --- source/blender/blenkernel/intern/layer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 784cd5b2edf..0757cf791b7 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -367,7 +367,13 @@ static void view_layer_bases_hash_create(ViewLayer *view_layer) LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (base->object) { - BLI_ghash_insert(hash, base->object, base); + /* Some processes, like ID remapping, may lead to having several bases with the same + * object. So just take the first one here, and ignore all others + * (#BKE_layer_collection_sync will clean this up anyway). */ + void **val_pp; + if (!BLI_ghash_ensure_p(hash, base->object, &val_pp)) { + *val_pp = base; + } } } -- cgit v1.2.3