From eab00bf2025284249c97c62b53a49a0d36cba54e Mon Sep 17 00:00:00 2001 From: mano-wii Date: Fri, 5 Oct 2018 11:55:17 -0300 Subject: GPU Python: fix crash when calling `batch.draw` without passing a shader. --- source/blender/python/gpu/gpu_py_batch.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c index c6acbcb0308..54574bda1f4 100644 --- a/source/blender/python/gpu/gpu_py_batch.c +++ b/source/blender/python/gpu/gpu_py_batch.c @@ -185,7 +185,13 @@ static PyObject *bpygpu_VertBatch_draw(BPyGPUBatch *self, PyObject *args) { return NULL; } - + else if (py_program == NULL) { + if (!glIsProgram(self->batch->program)) { + PyErr_SetString(PyExc_RuntimeError, + "batch does not have any program assigned to it"); + return NULL; + } + } else if (self->batch->program != GPU_shader_get_program(py_program->shader)) { GPU_batch_program_set(self->batch, GPU_shader_get_program(py_program->shader), @@ -199,8 +205,8 @@ static PyObject *bpygpu_VertBatch_draw(BPyGPUBatch *self, PyObject *args) static PyObject *bpygpu_VertBatch_program_use_begin(BPyGPUBatch *self) { if (!glIsProgram(self->batch->program)) { - PyErr_SetString(PyExc_ValueError, - "batch program has not not set"); + PyErr_SetString(PyExc_RuntimeError, + "batch does not have any program assigned to it"); } GPU_batch_program_use_begin(self->batch); Py_RETURN_NONE; @@ -209,8 +215,8 @@ static PyObject *bpygpu_VertBatch_program_use_begin(BPyGPUBatch *self) static PyObject *bpygpu_VertBatch_program_use_end(BPyGPUBatch *self) { if (!glIsProgram(self->batch->program)) { - PyErr_SetString(PyExc_ValueError, - "batch program has not not set"); + PyErr_SetString(PyExc_RuntimeError, + "batch does not have any program assigned to it"); } GPU_batch_program_use_end(self->batch); Py_RETURN_NONE; -- cgit v1.2.3