fix T40323 Segfault on baking after rendering

The remaining functions in blender_python.cpp changed from using the
MACRO to use python_thread_state_save/python_thread_state_restore

Since this bug only happens when 'Persistent Images' is on it was
introduced in some of the early merges with master and I never caught
it.

Thanks Daniel Salazar for helping with the bug hunting.
This commit is contained in:
Dalai Felinto 2014-05-22 20:18:45 -03:00
parent 81b129d3b8
commit dd96205d0a
Notes: blender-bot 2023-02-14 10:36:33 +01:00
Referenced by issue #40323, Segfault on baking after rendering
1 changed files with 3 additions and 3 deletions

View File

@ -158,8 +158,6 @@ static PyObject *bake_func(PyObject *self, PyObject *args)
if(!PyArg_ParseTuple(args, "OOsOiiO", &pysession, &pyobject, &pass_type, &pypixel_array, &num_pixels, &depth, &pyresult))
return NULL;
Py_BEGIN_ALLOW_THREADS
BlenderSession *session = (BlenderSession*)PyLong_AsVoidPtr(pysession);
PointerRNA objectptr;
@ -172,9 +170,11 @@ static PyObject *bake_func(PyObject *self, PyObject *args)
RNA_id_pointer_create((ID*)PyLong_AsVoidPtr(pypixel_array), &bakepixelptr);
BL::BakePixel b_bake_pixel(bakepixelptr);
python_thread_state_save(&session->python_thread_state);
session->bake(b_object, pass_type, b_bake_pixel, num_pixels, depth, (float *)b_result);
Py_END_ALLOW_THREADS
python_thread_state_restore(&session->python_thread_state);
Py_RETURN_NONE;
}