Added Python error handling to StrokeShader::shade(). Also made
a measure to avoid an infinite loop due to non-proper overriding of the shade method.
This commit is contained in:
@@ -289,8 +289,17 @@ PyObject *StrokeShader_shade( BPy_StrokeShader *self , PyObject *args) {
|
|||||||
if(!( PyArg_ParseTuple(args, "O!", &Stroke_Type, &py_s) ))
|
if(!( PyArg_ParseTuple(args, "O!", &Stroke_Type, &py_s) ))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
self->ss->shade(*( ((BPy_Stroke *) py_s)->s ));
|
if( typeid(*(self->ss)) == typeid(StrokeShader) ) {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "shade method not properly overridden");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (self->ss->shade(*( ((BPy_Stroke *) py_s)->s )) < 0) {
|
||||||
|
if (!PyErr_Occurred()) {
|
||||||
|
string msg(self->ss->getName() + " shade method failed");
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, msg.c_str());
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user