Commit: eab00bf2025284249c97c62b53a49a0d36cba54e
Author: mano-wii
Date: Fri Oct 5 11:55:17 2018 -0300
Branches: blender2.8
https://developer.blender.org/rBeab00bf2025284249c97c62b53a49a0d36cba54e
GPU Python: fix crash when calling `batch.draw` without passing a shader.
===================================================================
M source/blender/python/gpu/gpu_py_batch.c
===================================================================
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;
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs