[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50803] trunk/blender/source/blender/ python/intern/bpy_interface.c: fix for crash getting a member from the operator context override, in some cases python didnt hold the GIL.
Campbell Barton
ideasman42 at gmail.com
Sat Sep 22 00:31:03 CEST 2012
Revision: 50803
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50803
Author: campbellbarton
Date: 2012-09-21 22:31:02 +0000 (Fri, 21 Sep 2012)
Log Message:
-----------
fix for crash getting a member from the operator context override, in some cases python didnt hold the GIL.
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_interface.c
Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c 2012-09-21 21:43:56 UTC (rev 50802)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c 2012-09-21 22:31:02 UTC (rev 50803)
@@ -680,11 +680,20 @@
int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result)
{
- PyObject *pyctx = (PyObject *)CTX_py_dict_get(C);
- PyObject *item = PyDict_GetItemString(pyctx, member);
+ PyGILState_STATE gilstate;
+ int use_gil = !PYC_INTERPRETER_ACTIVE;
+
+ PyObject *pyctx;
+ PyObject *item;
PointerRNA *ptr = NULL;
int done = FALSE;
+ if (use_gil)
+ gilstate = PyGILState_Ensure();
+
+ pyctx = (PyObject *)CTX_py_dict_get(C);
+ item = PyDict_GetItemString(pyctx, member);
+
if (item == NULL) {
/* pass */
}
@@ -720,7 +729,8 @@
CTX_data_list_add(result, ptr->id.data, ptr->type, ptr->data);
}
else {
- printf("List item not a valid type\n");
+ printf("PyContext: '%s' list item not a valid type in sequece type '%s'\n",
+ member, Py_TYPE(item)->tp_name);
}
}
@@ -740,6 +750,9 @@
}
}
+ if (use_gil)
+ PyGILState_Release(gilstate);
+
return done;
}
More information about the Bf-blender-cvs
mailing list