Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormano-wii <germano.costa@ig.com.br>2018-10-05 17:55:17 +0300
committermano-wii <germano.costa@ig.com.br>2018-10-05 17:55:17 +0300
commiteab00bf2025284249c97c62b53a49a0d36cba54e (patch)
tree7c5c337ffeeedfe15bb1e6099bb6f406377fe6be /source/blender/python/gpu/gpu_py_batch.c
parent35dcc3d4f499f012c4cb6635abaacda558db4ff3 (diff)
GPU Python: fix crash when calling `batch.draw` without passing a shader.
Diffstat (limited to 'source/blender/python/gpu/gpu_py_batch.c')
-rw-r--r--source/blender/python/gpu/gpu_py_batch.c16
1 files changed, 11 insertions, 5 deletions
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;