diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-05-18 11:52:01 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-05-18 14:40:52 +0300 |
commit | 8540907d6067eee8645f7f079c7fc103bd068573 (patch) | |
tree | 97705eceaa8566c4c9642908f0d3f7a48218e471 /source/blender/blenkernel/intern | |
parent | 40091ff83aa2482db93855f53d1b4c7208a500ac (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 413e34e72a8..322da9f1095 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; |