Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-12-07 07:12:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-12-07 07:12:15 +0300
commitd624d1cbddf9ee51108e7eb89a6cfd7044fd57c0 (patch)
treed93701004cd4a3bdfabe8bd5f40b5e90eead91d1 /source/blender/python/intern/bpy_operator.c
parent48614fbc2af024d613845b03d632e544f8127261 (diff)
pass along the context to extension functions, this was already being done in all cases except for the render engine.
this allows python to NULL its internal context while scripts are not running.
Diffstat (limited to 'source/blender/python/intern/bpy_operator.c')
-rw-r--r--source/blender/python/intern/bpy_operator.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index ea8d39806db..ef7c1cc369a 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -52,8 +52,13 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
int context= WM_OP_EXEC_DEFAULT;
// XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
- bContext *C = BPy_GetContext();
+ bContext *C= (bContext *)BPy_GetContext();
+ if(C==NULL) {
+ PyErr_SetString(PyExc_SystemError, "Context is None, cant poll any operators");
+ return NULL;
+ }
+
if (!PyArg_ParseTuple(args, "s|Os:_bpy.ops.poll", &opname, &context_dict, &context_str))
return NULL;
@@ -114,7 +119,12 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
int context= WM_OP_EXEC_DEFAULT;
// XXX Todo, work out a better solution for passing on context, could make a tuple from self and pack the name and Context into it...
- bContext *C = BPy_GetContext();
+ bContext *C = (bContext *)BPy_GetContext();
+
+ if(C==NULL) {
+ PyErr_SetString(PyExc_SystemError, "Context is None, cant poll any operators");
+ return NULL;
+ }
if (!PyArg_ParseTuple(args, "sO|O!s:_bpy.ops.call", &opname, &context_dict, &PyDict_Type, &kw, &context_str))
return NULL;
@@ -232,8 +242,13 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
char *buf = NULL;
PyObject *pybuf;
- bContext *C = BPy_GetContext();
+ bContext *C = (bContext *)BPy_GetContext();
+ if(C==NULL) {
+ PyErr_SetString(PyExc_SystemError, "Context is None, cant get the string representation of this object.");
+ return NULL;
+ }
+
if (!PyArg_ParseTuple(args, "s|O!i:_bpy.ops.as_string", &opname, &PyDict_Type, &kw, &all_args))
return NULL;