[Bf-blender-cvs] [9cf966f] framebuffer: Raise an exception for invalid context (otherwise it crashes when calling it from the python console)

Dalai Felinto noreply at git.blender.org
Thu Oct 15 15:57:38 CEST 2015


Commit: 9cf966f6e0ff8907fc8c1908cdc49bfab39253df
Author: Dalai Felinto
Date:   Thu Oct 15 10:28:19 2015 -0300
Branches: framebuffer
https://developer.blender.org/rB9cf966f6e0ff8907fc8c1908cdc49bfab39253df

Raise an exception for invalid context (otherwise it crashes when calling it from the python console)

===================================================================

M	source/blender/python/intern/gpu_offscreen.c

===================================================================

diff --git a/source/blender/python/intern/gpu_offscreen.c b/source/blender/python/intern/gpu_offscreen.c
index 2c038ff..b4f5970 100644
--- a/source/blender/python/intern/gpu_offscreen.c
+++ b/source/blender/python/intern/gpu_offscreen.c
@@ -204,6 +204,8 @@ static PyObject *pygpu_offscreen_draw(PyGPUOffScreen *self, PyObject *args, PyOb
 	MatrixObject *PyModelViewMatrix;
 	MatrixObject *PyProjectionMatrix;
 	bContext *C;
+	View3D *v3d;
+	ARegion *ar;
 
 	static const char *kwlist[] = {"projection_matrix", "modelview_matrix", NULL};
 
@@ -220,6 +222,14 @@ static PyObject *pygpu_offscreen_draw(PyGPUOffScreen *self, PyObject *args, PyOb
 	}
 
 	C = BPy_GetContext();
+	v3d = CTX_wm_view3d(C);
+	ar = CTX_wm_region(C);
+
+	if ((v3d == NULL) || (ar == NULL)) {
+		PyErr_SetString(PyExc_SystemError, "draw: No valid view3d in the context");
+		return NULL;
+	}
+
 	GPU_offscreen_draw(self->ofs, C, (float(*)[4])PyProjectionMatrix->matrix, (float(*)[4])PyModelViewMatrix->matrix);
 
 	Py_RETURN_NONE;




More information about the Bf-blender-cvs mailing list