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.
This commit is contained in:
@@ -223,7 +223,7 @@ void BPy_init_modules( void )
|
||||
PyModule_AddObject( mod, "app", BPY_app_struct() );
|
||||
|
||||
/* bpy context */
|
||||
RNA_pointer_create(NULL, &RNA_Context, BPy_GetContext(), &ctx_ptr);
|
||||
RNA_pointer_create(NULL, &RNA_Context, (void *)BPy_GetContext(), &ctx_ptr);
|
||||
bpy_context_module= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ctx_ptr);
|
||||
/* odd that this is needed, 1 ref on creation and another for the module
|
||||
* but without we get a crash on exit */
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -5125,7 +5125,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
|
||||
extern void BPY_update_modules( void ); //XXX temp solution
|
||||
|
||||
/* TODO - multiple return values like with rna functions */
|
||||
static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
|
||||
static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms)
|
||||
{
|
||||
PyObject *args;
|
||||
PyObject *ret= NULL, *py_srna= NULL, *py_class, *py_class_instance= NULL, *parmitem;
|
||||
@@ -5141,7 +5141,6 @@ static int bpy_class_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *par
|
||||
|
||||
PyGILState_STATE gilstate;
|
||||
|
||||
bContext *C= BPy_GetContext(); // XXX - NEEDS FIXING, QUITE BAD.
|
||||
#ifdef USE_PEDANTIC_WRITE
|
||||
/* testing, for correctness, not operator and not draw function */
|
||||
const short is_readonly= strstr("draw", RNA_function_identifier(func)) || !RNA_struct_is_a(ptr->type, &RNA_Operator);
|
||||
|
Reference in New Issue
Block a user