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
diff options
context:
space:
mode:
authorBastien Montagne <bastien@blender.org>2020-11-10 19:12:36 +0300
committerBastien Montagne <bastien@blender.org>2020-11-10 19:16:28 +0300
commit339f442a9327d6eeb1bc7a52be702ea9b461df72 (patch)
tree180b6e4bdaea37d6fbaf1d6b7949fdd3c098114b
parent626a79204ee2a9023cca1f7b9dfd88aa8d25cfc6 (diff)
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.
-rw-r--r--source/blender/blenkernel/intern/layer.c8
1 files changed, 7 insertions, 1 deletions
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;
+ }
}
}