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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-07-03 12:04:12 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-07-03 12:06:29 +0300
commita94d582a40ffc06b19f0e4af6ba107c1433fcb1e (patch)
tree4a443afc0337e89125c7bfd37b3d9da168e2fd67 /source/blender/editors/sculpt_paint
parenta9211e808c10fa267dbca2baa705560a5d980526 (diff)
Sculpt: Fix possible race condition with undo nodes
it is possible that two threads will request same undo node, only one of them will initialize the node. The issue is that initialization is happening outside of a lock, which was making one thread to use non- initialized node. If this change is ever a bottleneck, make a lock inside of node.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index bc22147b15d..61f7c3bd0d9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -931,9 +931,10 @@ SculptUndoNode *sculpt_undo_push_node(
unode = sculpt_undo_alloc_node(ob, node, type);
- BLI_thread_unlock(LOCK_CUSTOM1);
-
- /* copy threaded, hopefully this is the performance critical part */
+ /* NOTE: If this ever becomes a bottleneck, make a lock inside of the node.
+ * so we release global lock sooner, but keep data locked for until it is
+ * fully initialized.
+ */
if (unode->grids) {
int totgrid, *grids;
@@ -970,6 +971,8 @@ SculptUndoNode *sculpt_undo_push_node(
if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name));
else unode->shapeName[0] = '\0';
+ BLI_thread_unlock(LOCK_CUSTOM1);
+
return unode;
}