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_operator.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_operator.c')
-rw-r--r--source/blender/python/intern/bpy_operator.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index b8883e655f2..4a17c45ae38 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -55,6 +55,10 @@
#include "BKE_report.h"
#include "BKE_context.h"
+/* so operators called can spawn threads which aquire the GIL */
+#define BPY_RELEASE_GIL
+
+
static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
@@ -219,7 +223,22 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
reports= MEM_mallocN(sizeof(ReportList), "wmOperatorReportList");
BKE_reports_init(reports, RPT_STORE | RPT_OP_HOLD); /* own so these dont move into global reports */
- operator_ret= WM_operator_call_py(C, ot, context, &ptr, reports);
+#ifdef BPY_RELEASE_GIL
+ /* release GIL, since a thread could be started from an operator
+ * that updates a driver */
+ /* note: I havve not seen any examples of code that does this
+ * so it may not be officially supported but seems to work ok. */
+ {
+ PyThreadState *ts= PyEval_SaveThread();
+#endif
+
+ operator_ret= WM_operator_call_py(C, ot, context, &ptr, reports);
+
+#ifdef BPY_RELEASE_GIL
+ /* regain GIL */
+ PyEval_RestoreThread(ts);
+ }
+#endif
error_val= BPy_reports_to_error(reports, PyExc_RuntimeError, FALSE);