Fix T59773: Raise exception if the gpu module is used in backgound mode.

Instead of crashing, an error message is displayed if a function of the gpu module is called without a GPU context.

Reviewers: brecht, campbellbarton, JacquesLucke, mont29

Subscribers: abdelmatinboulbayam, amir.shehata

Differential Revision: https://developer.blender.org/D4143
This commit is contained in:
2019-01-02 10:01:46 -02:00
parent c862c14339
commit 945007b32e
12 changed files with 113 additions and 128 deletions

View File

@@ -53,6 +53,7 @@
#include "../generic/py_capi_utils.h"
#include "gpu_py.h"
#include "gpu_py_offscreen.h" /* own include */
@@ -93,7 +94,8 @@ static PyObject *bpygpu_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args
static const char *_keywords[] = {"width", "height", "samples", NULL};
static _PyArg_Parser _parser = {"ii|i:GPUOffScreen.__new__", _keywords, 0};
if (!_PyArg_ParseTupleAndKeywordsFast(
if (!bpygpu_is_initialized() ||
!_PyArg_ParseTupleAndKeywordsFast(
args, kwds, &_parser,
&width, &height, &samples))
{