[Bf-blender-cvs] [4102e7ed81c] master: Fix T77032: Crash when creating GPUOffscreen without GPUContext in Python
Germano Cavalcante
noreply at git.blender.org
Tue May 26 16:38:29 CEST 2020
Commit: 4102e7ed81cb2c98dc0ade362f47843c7c13b5a7
Author: Germano Cavalcante
Date: Tue May 26 11:38:09 2020 -0300
Branches: master
https://developer.blender.org/rB4102e7ed81cb2c98dc0ade362f47843c7c13b5a7
Fix T77032: Crash when creating GPUOffscreen without GPUContext in Python
===================================================================
M source/blender/python/gpu/gpu_py_offscreen.c
===================================================================
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,
More information about the Bf-blender-cvs
mailing list