fix for a bug running a script, then opening a new file.

BPY_text_free_code() could run outside the python interpreter which abort()'s blender.
This commit is contained in:
Campbell Barton
2012-09-10 23:32:46 +00:00
parent 16e48ff958
commit cf5da37e3c

View File

@@ -163,8 +163,17 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
void BPY_text_free_code(Text *text)
{
if (text->compiled) {
PyGILState_STATE gilstate;
int use_gil = !PYC_INTERPRETER_ACTIVE;
if (use_gil)
gilstate = PyGILState_Ensure();
Py_DECREF((PyObject *)text->compiled);
text->compiled = NULL;
if (use_gil)
PyGILState_Release(gilstate);
}
}