diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-09-11 03:32:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-09-11 03:32:46 +0400 |
commit | cf5da37e3c4c8ed4bf5e0427d06b0e5c55f2059c (patch) | |
tree | 9a830d6fbeb3a30e339d59c2bc561b527800045e /source/blender/python | |
parent | 16e48ff9580fcaf0da46e9044ee0d6e10ccb662e (diff) |
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.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 1c63ab512f2..9cd0bdd090a 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -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); } } |