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:
authorCampbell Barton <ideasman42@gmail.com>2021-03-04 15:09:11 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-03-04 15:09:11 +0300
commitd9e567d36573bf81549ea5c4914a65b3a21dafcc (patch)
treedc0f69e137c75a1953f061212628207f13e830d6
parent7fd6c7f3718a1a7db5924366d5f8f2d03902bf74 (diff)
PyAPI: support methods for collection properties
Previously only static methods were supported. Now C/API functions added to collections can receive a 'self' argument.
-rw-r--r--source/blender/python/intern/bpy_rna.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index a006b81cb60..bad6c4b4b56 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -4622,6 +4622,19 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject
if (ret == NULL) {
PyErr_Restore(error_type, error_value, error_traceback);
}
+ else {
+ if (Py_TYPE(ret) == &PyMethodDescr_Type) {
+ PyMethodDef *m = ((PyMethodDescrObject *)ret)->d_method;
+ /* TODO: #METH_CLASS */
+ if (m->ml_flags & METH_STATIC) {
+ /* Keep 'ret' as-is. */
+ }
+ else {
+ Py_DECREF(ret);
+ ret = PyCMethod_New(m, (PyObject *)self, NULL, NULL);
+ }
+ }
+ }
}
}