handle possible crashes with FaceMaker and fix a few coding flaws

This commit is contained in:
wmayer
2016-10-02 14:47:59 +02:00
parent 679bb2f5a8
commit da406cddb8
11 changed files with 48 additions and 28 deletions

View File

@@ -251,9 +251,14 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* pcPyShapeOrList = nullptr;
PyErr_Clear();
if (PyArg_ParseTuple(args, "Os", &pcPyShapeOrList, &className)) {
try{
try {
std::unique_ptr<FaceMaker> fm_instance = Part::FaceMaker::ConstructFromType(className);
FaceMaker* fm = &(*fm_instance);
FaceMaker* fm = fm_instance.get();
if (!fm) {
std::stringstream out;
out << "Cannot create FaceMaker from abstract type " << className;
throw Base::TypeError(out.str());
}
//dump all supplied shapes to facemaker, no matter what type (let facemaker decide).
if (PySequence_Check(pcPyShapeOrList)){
@@ -293,7 +298,7 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return -1;
}
} ;
}
PyErr_SetString(PartExceptionOCCError,
"Argument list signature is incorrect.\n\nSupported signatures:\n"