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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user