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:
Diffstat (limited to 'source/blender/python/generic/bpy_threads.c')
-rw-r--r--source/blender/python/generic/bpy_threads.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/python/generic/bpy_threads.c b/source/blender/python/generic/bpy_threads.c
index bd707f728a1..8aa8c5c5d92 100644
--- a/source/blender/python/generic/bpy_threads.c
+++ b/source/blender/python/generic/bpy_threads.c
@@ -29,8 +29,12 @@
/* analogue of PyEval_SaveThread() */
BPy_ThreadStatePtr BPY_thread_save(void)
{
- /* The thread-state can be NULL when quitting Blender. */
- if (_PyThreadState_UncheckedGet()) {
+ /* Use `_PyThreadState_UncheckedGet()` instead of `PyThreadState_Get()`, to avoid a fatal error
+ * issued when a thread state is NULL (the thread state can be NULL when quitting Blender).
+ *
+ * `PyEval_SaveThread()` will release the GIL, so this thread has to have the GIL to begin with
+ * or badness will ensue. */
+ if (_PyThreadState_UncheckedGet() && PyGILState_Check()) {
return (BPy_ThreadStatePtr)PyEval_SaveThread();
}
return NULL;