[Bf-blender-cvs] [339f442a932] master: Fix (unreported) potential assert in viewlayer synchronization.

Bastien Montagne noreply at git.blender.org
Tue Nov 10 17:16:40 CET 2020


Commit: 339f442a9327d6eeb1bc7a52be702ea9b461df72
Author: Bastien Montagne
Date:   Tue Nov 10 17:12:36 2020 +0100
Branches: master
https://developer.blender.org/rB339f442a9327d6eeb1bc7a52be702ea9b461df72

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.

===================================================================

M	source/blender/blenkernel/intern/layer.c

===================================================================

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;
+          }
         }
       }



More information about the Bf-blender-cvs mailing list