diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-05-26 17:38:09 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-05-26 17:38:19 +0300 |
commit | 4102e7ed81cb2c98dc0ade362f47843c7c13b5a7 (patch) | |
tree | f12dda5da63e108ade929fff59a392c086a23319 /source/blender | |
parent | d8733539b70a1f1f0cec8650ff6057c8ef0f3ae6 (diff) |
Fix T77032: Crash when creating GPUOffscreen without GPUContext in Python
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/gpu/gpu_py_offscreen.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c index 280f09d67c9..311cf2b8c73 100644 --- a/source/blender/python/gpu/gpu_py_offscreen.c +++ b/source/blender/python/gpu/gpu_py_offscreen.c @@ -40,6 +40,7 @@ #include "DNA_screen_types.h" #include "DNA_view3d_types.h" +#include "GPU_context.h" #include "GPU_framebuffer.h" #include "GPU_texture.h" @@ -84,7 +85,7 @@ static PyObject *bpygpu_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args { BPYGPU_IS_INIT_OR_ERROR_OBJ; - GPUOffScreen *ofs; + GPUOffScreen *ofs = NULL; int width, height, samples = 0; char err_out[256]; @@ -94,7 +95,12 @@ static PyObject *bpygpu_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args return NULL; } - ofs = GPU_offscreen_create(width, height, samples, true, false, err_out); + if (GPU_context_active_get()) { + ofs = GPU_offscreen_create(width, height, samples, true, false, err_out); + } + else { + strncpy(err_out, "No active GPU context found", 256); + } if (ofs == NULL) { PyErr_Format(PyExc_RuntimeError, |