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:
authorBrecht Van Lommel <brecht@blender.org>2020-10-02 20:30:19 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-10-02 20:42:20 +0300
commit38cdc7bcc1f2ac7e89578be079e4be0b049a4036 (patch)
treeec1c03a178844f105e0a6bf3ba66ce97bf2207b3 /source/blender/blenkernel/intern/layer.c
parent350ed861f149142784fc184086e92664b72a10ef (diff)
Fix non-thread safe code in view layer object hash
Found as part of D8324, multithreaded Cycles object sync, where it caused a crash on concurrent access to object holdout state.
Diffstat (limited to 'source/blender/blenkernel/intern/layer.c')
-rw-r--r--source/blender/blenkernel/intern/layer.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 1d47fb002e6..4ed8a796d5d 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -358,14 +358,16 @@ static void view_layer_bases_hash_create(ViewLayer *view_layer)
BLI_mutex_lock(&hash_lock);
if (view_layer->object_bases_hash == NULL) {
- view_layer->object_bases_hash = BLI_ghash_new(
- BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+ GHash *hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object) {
- BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
+ BLI_ghash_insert(hash, base->object, base);
}
}
+
+ /* Assign pointer only after hash is complete. */
+ view_layer->object_bases_hash = hash;
}
BLI_mutex_unlock(&hash_lock);