[Bf-blender-cvs] [0f583d9d604] master: PyAPI: support persistent handlers for class & static methods

Campbell Barton noreply at git.blender.org
Tue Apr 26 05:49:14 CEST 2022


Commit: 0f583d9d604f45606e238f88eb2300eb75e492bb
Author: Campbell Barton
Date:   Tue Apr 26 13:46:06 2022 +1000
Branches: master
https://developer.blender.org/rB0f583d9d604f45606e238f88eb2300eb75e492bb

PyAPI: support persistent handlers for class & static methods

Support methods being used as persistent callbacks.

Resolves T97555.

===================================================================

M	source/blender/python/intern/bpy_app_handlers.c

===================================================================

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 */
         }



More information about the Bf-blender-cvs mailing list