[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45040] trunk/blender/source/blender/ python/intern/bpy_app_handlers.c: fix to possible bug running python callbacks - bpy.app.handlers. * to support handlers removing themselves from the list.
Campbell Barton
ideasman42 at gmail.com
Tue Mar 20 21:37:41 CET 2012
Revision: 45040
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45040
Author: campbellbarton
Date: 2012-03-20 20:37:40 +0000 (Tue, 20 Mar 2012)
Log Message:
-----------
fix to possible bug running python callbacks - bpy.app.handlers.* to support handlers removing themselves from the list.
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_app_handlers.c
Modified: trunk/blender/source/blender/python/intern/bpy_app_handlers.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_app_handlers.c 2012-03-20 20:32:17 UTC (rev 45039)
+++ trunk/blender/source/blender/python/intern/bpy_app_handlers.c 2012-03-20 20:37:40 UTC (rev 45040)
@@ -279,8 +279,7 @@
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 @@
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) {
More information about the Bf-blender-cvs
mailing list