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>2012-03-21 00:37:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-21 00:37:40 +0400
commit7dda8182ad65ae1d7507ae33e198d2031666f8e7 (patch)
tree338e9eac366031cecd7e7df6a7c5f59f28a01b2e /source/blender/python/intern/bpy_app_handlers.c
parentd74ab9d598b2eee465c7751c9c571750d729b804 (diff)
fix to possible bug running python callbacks - bpy.app.handlers.* to support handlers removing themselves from the list.
Diffstat (limited to 'source/blender/python/intern/bpy_app_handlers.c')
-rw-r--r--source/blender/python/intern/bpy_app_handlers.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c
index 54848161b89..2974e3cf3cb 100644
--- a/source/blender/python/intern/bpy_app_handlers.c
+++ b/source/blender/python/intern/bpy_app_handlers.c
@@ -279,8 +279,7 @@ void BPY_app_handlers_reset(const short do_all)
void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *arg)
{
PyObject *cb_list = py_cb_array[GET_INT_FROM_POINTER(arg)];
- Py_ssize_t cb_list_len;
- if ((cb_list_len = PyList_GET_SIZE(cb_list)) > 0) {
+ if (PyList_GET_SIZE(cb_list) > 0) {
PyGILState_STATE gilstate = PyGILState_Ensure();
PyObject *args = PyTuple_New(1); // save python creating each call
@@ -299,8 +298,9 @@ void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *ar
Py_INCREF(Py_None);
}
- // Iterate the list and run the callbacks
- for (pos = 0; pos < cb_list_len; pos++) {
+ /* Iterate the list and run the callbacks
+ * note: don't store the list size since the scripts may remove themselves */
+ for (pos = 0; pos < PyList_GET_SIZE(cb_list); pos++) {
func = PyList_GET_ITEM(cb_list, pos);
ret = PyObject_Call(func, args, NULL);
if (ret == NULL) {