forked from bartvdbraak/blender
fixed some error reporting issues with calling operators
This commit is contained in:
parent
4c03ce9100
commit
052290d2b3
@ -76,7 +76,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args)
|
|||||||
Py_XINCREF(context_dict); /* so we done loose it */
|
Py_XINCREF(context_dict); /* so we done loose it */
|
||||||
|
|
||||||
if(WM_operator_poll((bContext*)C, ot) == FALSE) {
|
if(WM_operator_poll((bContext*)C, ot) == FALSE) {
|
||||||
PyErr_SetString( PyExc_SystemError, "_bpy.ops.call: operator poll() function failed, context is incorrect");
|
PyErr_Format( PyExc_SystemError, "_bpy.ops.call: operator %.200s.poll() function failed, context is incorrect", opname);
|
||||||
error_val= -1;
|
error_val= -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -105,7 +105,11 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
|
|||||||
py_class_instance = PyObject_Call(py_class, args, NULL);
|
py_class_instance = PyObject_Call(py_class, args, NULL);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (py_class_instance) { /* Initializing the class worked, now run its invoke function */
|
if (py_class_instance==NULL) { /* Initializing the class worked, now run its invoke function */
|
||||||
|
PyErr_Print();
|
||||||
|
PyErr_Clear();
|
||||||
|
}
|
||||||
|
else {
|
||||||
RNA_pointer_create(NULL, &RNA_Context, C, &ptr_context);
|
RNA_pointer_create(NULL, &RNA_Context, C, &ptr_context);
|
||||||
|
|
||||||
if (mode==PYOP_INVOKE) {
|
if (mode==PYOP_INVOKE) {
|
||||||
@ -137,10 +141,6 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
|
|||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
PyErr_Print();
|
|
||||||
PyErr_Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == NULL) { /* covers py_class_instance failing too */
|
if (ret == NULL) { /* covers py_class_instance failing too */
|
||||||
if(op)
|
if(op)
|
||||||
@ -149,9 +149,8 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
|
|||||||
else {
|
else {
|
||||||
if (mode==PYOP_POLL) {
|
if (mode==PYOP_POLL) {
|
||||||
if (PyBool_Check(ret) == 0) {
|
if (PyBool_Check(ret) == 0) {
|
||||||
PyErr_SetString(PyExc_ValueError, "Python poll function return value ");
|
PyErr_Format(PyExc_ValueError, "Python operator '%s.poll', did not return a bool value", ot->idname);
|
||||||
if(op)
|
BPy_errors_to_report(op ? op->reports:NULL); /* prints and clears if NULL given */
|
||||||
BPy_errors_to_report(op->reports);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret_flag= ret==Py_True ? 1:0;
|
ret_flag= ret==Py_True ? 1:0;
|
||||||
@ -159,11 +158,8 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
|
|||||||
|
|
||||||
} else if (BPY_flag_from_seq(pyop_ret_flags, ret, &ret_flag) == -1) {
|
} else if (BPY_flag_from_seq(pyop_ret_flags, ret, &ret_flag) == -1) {
|
||||||
/* the returned value could not be converted into a flag */
|
/* the returned value could not be converted into a flag */
|
||||||
if(op) {
|
PyErr_Format(PyExc_ValueError, "Python operator, error using return value from \"%s\"\n", ot->idname);
|
||||||
fprintf(stderr, "error using return value from \"%s\"\n", op->idname); // for some reason the error raised doesnt include file:line... this helps
|
BPy_errors_to_report(op ? op->reports:NULL);
|
||||||
BPy_errors_to_report(op->reports);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret_flag = OPERATOR_CANCELLED;
|
ret_flag = OPERATOR_CANCELLED;
|
||||||
}
|
}
|
||||||
/* there is no need to copy the py keyword dict modified by
|
/* there is no need to copy the py keyword dict modified by
|
||||||
|
Loading…
Reference in New Issue
Block a user