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:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-02-24 19:54:57 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-02-24 19:57:06 +0300
commit5dd176cde8aa04132e9ffaa02c95ccf1022bc217 (patch)
tree23b845b8b70ff0b852e658882e33f20da8d9b17a
parentb0b33b77fae0d3def497fcbab6fa3ac85abaa98b (diff)
PyAPI: Ensure GIL state only when a callback exists
There are fewer python callbacks than `ARegionType`s. This also broke GTests's `bf_blenderloader_tests`.
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index fdd3cb363ea..7f8ea54ab98 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -495,21 +495,28 @@ PyObject *pyrna_callback_classmethod_remove(PyObject *UNUSED(self), PyObject *ar
static void cb_customdata_free(void *customdata)
{
PyObject *tuple = customdata;
+ bool use_gil = true; /* !PyC_IsInterpreterActive(); */
+
+ PyGILState_STATE gilstate;
+ if (use_gil) {
+ gilstate = PyGILState_Ensure();
+ }
+
Py_DECREF(tuple);
+
+ if (use_gil) {
+ PyGILState_Release(gilstate);
+ }
}
void BPY_callback_screen_free(struct ARegionType *art)
{
- PyGILState_STATE gilstate = PyGILState_Ensure();
ED_region_draw_cb_remove_by_type(art, cb_region_draw, cb_customdata_free);
- PyGILState_Release(gilstate);
}
void BPY_callback_wm_free(struct wmWindowManager *wm)
{
- PyGILState_STATE gilstate = PyGILState_Ensure();
WM_paint_cursor_remove_by_type(wm, cb_wm_cursor_draw, cb_customdata_free);
- PyGILState_Release(gilstate);
}
/** \} */