[Bf-blender-cvs] [8540907] master: Attempt to make drivers more safe for threading

Sergey Sharybin noreply at git.blender.org
Mon May 18 13:41:02 CEST 2015


Commit: 8540907d6067eee8645f7f079c7fc103bd068573
Author: Sergey Sharybin
Date:   Mon May 18 13:52:01 2015 +0500
Branches: master
https://developer.blender.org/rB8540907d6067eee8645f7f079c7fc103bd068573

Attempt to make drivers more safe for threading

There were some reported data race conditions in the python interpreter which
seems to be rather valid.

Surely this is not very pretty solution, but it might solve some annoying bugs
related on threading.

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

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

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

diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 413e34e..322da9f 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -46,6 +46,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_easing.h"
+#include "BLI_threads.h"
 #include "BLI_utildefines.h"
 
 #include "BLF_translation.h"
@@ -69,6 +70,8 @@
 #define SMALL -1.0e-10
 #define SELECT 1
 
+static ThreadMutex python_driver_lock = BLI_MUTEX_INITIALIZER;
+
 /* ************************** Data-Level Functions ************************* */
 
 /* ---------------------- Freeing --------------------------- */
@@ -1807,7 +1810,9 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
 				/* this evaluates the expression using Python, and returns its result:
 				 *  - on errors it reports, then returns 0.0f
 				 */
+				BLI_mutex_lock(&python_driver_lock);
 				driver->curval = BPY_driver_exec(driver, evaltime);
+				BLI_mutex_unlock(&python_driver_lock);
 			}
 #else /* WITH_PYTHON*/
 			(void)evaltime;




More information about the Bf-blender-cvs mailing list