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:
authorCampbell Barton <ideasman42@gmail.com>2011-08-04 05:56:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-08-04 05:56:36 +0400
commite5e6f91856efe3d78eab747c25be4e1d0a5988ef (patch)
tree5661b9e89f0baf436d5c15e66f2a5ebaa1dfb454 /source/blender/python/intern/bpy_driver.c
parent79c87852d2a2b07ba3cb411e00fd0fb4aaee008a (diff)
fix [#28114] Render Crash
existing check for driver to use GIL was not thread safe and could cause, details in the report. This bug was caused by a check to avoid hanging, a fix for [#27683] that worked in 2.4x because the UI didn't use python to draw while rendering. Apply a different fix for [#27683], when calling an operator, call PyEval_SaveThread(), then PyEval_RestoreThread() so the GIL can be aquired by threads started by the operator - in this case bake starting a thread that evaluates drivers.
Diffstat (limited to 'source/blender/python/intern/bpy_driver.c')
-rw-r--r--source/blender/python/intern/bpy_driver.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index bcd5df97c2c..d68fd9a9111 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -41,8 +41,6 @@
#include "bpy_driver.h"
-#include "../generic/py_capi_utils.h"
-
/* for pydrivers (drivers using one-line Python expressions to express relationships between targets) */
PyObject *bpy_pydriver_Dict= NULL;
@@ -89,7 +87,7 @@ int bpy_pydriver_create_dict(void)
void BPY_driver_reset(void)
{
PyGILState_STATE gilstate;
- int use_gil= !PYC_INTERPRETER_ACTIVE;
+ int use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
if(use_gil)
gilstate= PyGILState_Ensure();
@@ -120,9 +118,14 @@ static void pydriver_error(ChannelDriver *driver)
/* This evals py driver expressions, 'expr' is a Python expression that
* should evaluate to a float number, which is returned.
*
- * note: PyGILState_Ensure() isnt always called because python can call the
- * bake operator which intern starts a thread which calls scene update which
- * does a driver update. to avoid a deadlock check PYC_INTERPRETER_ACTIVE if PyGILState_Ensure() is needed.
+ * (old)note: PyGILState_Ensure() isnt always called because python can call
+ * the bake operator which intern starts a thread which calls scene update
+ * which does a driver update. to avoid a deadlock check PYC_INTERPRETER_ACTIVE
+ * if PyGILState_Ensure() is needed - see [#27683]
+ *
+ * (new)note: checking if python is running is not threadsafe [#28114]
+ * now release the GIL on python operator execution instead, using
+ * PyEval_SaveThread() / PyEval_RestoreThread() so we dont lock up blender.
*/
float BPY_driver_exec(ChannelDriver *driver)
{
@@ -149,7 +152,7 @@ float BPY_driver_exec(ChannelDriver *driver)
return 0.0f;
}
- use_gil= !PYC_INTERPRETER_ACTIVE;
+ use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
if(use_gil)
gilstate= PyGILState_Ensure();