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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-04-26 06:46:06 +0300
committerCampbell Barton <campbell@blender.org>2022-04-26 06:47:24 +0300
commit0f583d9d604f45606e238f88eb2300eb75e492bb (patch)
tree57cd815d38b3db499c3f28b4eb88805e642145e6 /source
parent07e2bd443ea2b3aadb78bcbb8b74950917a0181d (diff)
PyAPI: support persistent handlers for class & static methods
Support methods being used as persistent callbacks. Resolves T97555.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 34ffef03e66..319ca7baea1 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -266,13 +266,18 @@ void BPY_app_handlers_reset(const short do_all)
PyObject *ls = py_cb_array[pos];
Py_ssize_t i;
- PyObject *item;
- PyObject **dict_ptr;
-
for (i = PyList_GET_SIZE(ls) - 1; i >= 0; i--) {
+ PyObject *item = PyList_GET_ITEM(ls, i);
+
+ if (PyMethod_Check(item)) {
+ PyObject *item_test = PyMethod_GET_FUNCTION(item);
+ if (item_test) {
+ item = item_test;
+ }
+ }
- if (PyFunction_Check((item = PyList_GET_ITEM(ls, i))) &&
- (dict_ptr = _PyObject_GetDictPtr(item)) && (*dict_ptr) &&
+ PyObject **dict_ptr;
+ if (PyFunction_Check(item) && (dict_ptr = _PyObject_GetDictPtr(item)) && (*dict_ptr) &&
(PyDict_GetItem(*dict_ptr, perm_id_str) != NULL)) {
/* keep */
}