fix for crash getting a member from the operator context override, in some cases python didnt hold the GIL.

This commit is contained in:
Campbell Barton 2012-09-21 22:31:02 +00:00
parent 7f351d3b96
commit 537c3375b5

@ -680,11 +680,20 @@ void BPY_modules_load_user(bContext *C)
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 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
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 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
}
}
if (use_gil)
PyGILState_Release(gilstate);
return done;
}