blob: a1de7b401485ec3be92fc4041325364a4d082d74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
diff --git a/source/blender/python/generic/bpy_threads.c b/source/blender/python/generic/bpy_threads.c
index 5507aa73183..4807c1f5071 100644
--- a/source/blender/python/generic/bpy_threads.c
+++ b/source/blender/python/generic/bpy_threads.c
@@ -29,14 +29,11 @@
/* analogue of PyEval_SaveThread() */
BPy_ThreadStatePtr BPY_thread_save(void)
{
- PyThreadState *tstate = PyThreadState_Swap(NULL);
- /* note: tstate can be NULL when quitting Blender */
-
- if (tstate && PyEval_ThreadsInitialized()) {
- PyEval_ReleaseLock();
+ /* The thread-state can be NULL when quitting Blender. */
+ if (_PyThreadState_UncheckedGet()) {
+ return (BPy_ThreadStatePtr)PyEval_SaveThread();
}
-
- return (BPy_ThreadStatePtr)tstate;
+ return NULL;
}
/* analogue of PyEval_RestoreThread() */
|