From d3a96e5022e121426c8926d0507effe4e9b4005f Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Wed, 24 Feb 2021 15:13:24 -0300 Subject: t --- source/blender/python/intern/bpy_rna_callback.c | 29 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c index 7f8ea54ab98..34c1b8e84d6 100644 --- a/source/blender/python/intern/bpy_rna_callback.c +++ b/source/blender/python/intern/bpy_rna_callback.c @@ -24,6 +24,7 @@ #include #include "../generic/python_utildefines.h" +#include "../generic/py_capi_utils.h" #include "DNA_space_types.h" @@ -495,28 +496,40 @@ 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(); */ + + Py_DECREF(tuple); +} + +void BPY_callback_screen_free(struct ARegionType *art) +{ + bool use_gil = !PyC_IsInterpreterActive(); PyGILState_STATE gilstate; if (use_gil) { gilstate = PyGILState_Ensure(); } - - Py_DECREF(tuple); + ED_region_draw_cb_remove_by_type(art, cb_region_draw, cb_customdata_free); if (use_gil) { PyGILState_Release(gilstate); } } -void BPY_callback_screen_free(struct ARegionType *art) -{ - ED_region_draw_cb_remove_by_type(art, cb_region_draw, cb_customdata_free); -} - void BPY_callback_wm_free(struct wmWindowManager *wm) { + bool use_gil = !PyC_IsInterpreterActive(); + + PyGILState_STATE gilstate; + if (use_gil) { + gilstate = PyGILState_Ensure(); + } + + BLI_assert(PyC_IsInterpreterActive()); WM_paint_cursor_remove_by_type(wm, cb_wm_cursor_draw, cb_customdata_free); + + if (use_gil) { + PyGILState_Release(gilstate); + } } /** \} */ -- cgit v1.2.3