From dd96205d0aaae39e8d49cae2a0b4a63b34a8c39d Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Thu, 22 May 2014 20:18:45 -0300 Subject: [PATCH] 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. --- intern/cycles/blender/blender_python.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 872f891cc2a..6148f49a4b4 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -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; }