Fix T42005: Reset py-handlers could crash

Wasn't acquiring the GIL.
This commit is contained in:
Campbell Barton 2014-10-13 17:44:27 +02:00
parent e72d8b4711
commit cf38b933f3
Notes: blender-bot 2023-02-14 10:02:22 +01:00
Referenced by issue #42005, Lambda as scene_update_pre handler may crash Blender upon unload
1 changed files with 5 additions and 0 deletions

View File

@ -240,8 +240,11 @@ PyObject *BPY_app_handlers_struct(void)
void BPY_app_handlers_reset(const short do_all)
{
PyGILState_STATE gilstate;
int pos = 0;
gilstate = PyGILState_Ensure();
if (do_all) {
for (pos = 0; pos < BLI_CB_EVT_TOT; pos++) {
/* clear list */
@ -279,6 +282,8 @@ void BPY_app_handlers_reset(const short do_all)
Py_DECREF(perm_id_str);
}
PyGILState_Release(gilstate);
}
/* the actual callback - not necessarily called from py */