diff --git a/src/Mod/Fem/App/FemPostFilterPyImp.cpp b/src/Mod/Fem/App/FemPostFilterPyImp.cpp index 3b27e3bf2d..7cac967a01 100644 --- a/src/Mod/Fem/App/FemPostFilterPyImp.cpp +++ b/src/Mod/Fem/App/FemPostFilterPyImp.cpp @@ -56,44 +56,49 @@ PyObject* FemPostFilterPy::addFilterPipeline(PyObject* args) const char* name; PyObject* source = nullptr; PyObject* target = nullptr; - - if (PyArg_ParseTuple(args, "sOO", &name, &source, &target)) { - - // extract the algorithms - vtkObjectBase* obj = vtkPythonUtil::GetPointerFromObject(source, "vtkAlgorithm"); - if (!obj) { - // error marker is set by PythonUtil - return nullptr; - } - auto source_algo = static_cast(obj); - - obj = vtkPythonUtil::GetPointerFromObject(target, "vtkAlgorithm"); - if (!obj) { - // error marker is set by PythonUtil - return nullptr; - } - auto target_algo = static_cast(obj); - - // add the pipeline - FemPostFilter::FilterPipeline pipe; - pipe.source = source_algo; - pipe.target = target_algo; - getFemPostFilterPtr()->addFilterPipeline(pipe, name); + PyTypeObject* typeAlgo = vtkPythonUtil::FindClassTypeObject("vtkAlgorithm"); + if (!PyArg_ParseTuple(args, "sO!O!", &name, typeAlgo, &source, typeAlgo, &target)) { + return nullptr; } + + // extract the algorithms + vtkObjectBase* obj = vtkPythonUtil::GetPointerFromObject(source, "vtkAlgorithm"); + if (!obj) { + // error marker is set by PythonUtil + return nullptr; + } + auto source_algo = static_cast(obj); + + obj = vtkPythonUtil::GetPointerFromObject(target, "vtkAlgorithm"); + if (!obj) { + // error marker is set by PythonUtil + return nullptr; + } + auto target_algo = static_cast(obj); + + // add the pipeline + FemPostFilter::FilterPipeline pipe; + pipe.source = source_algo; + pipe.target = target_algo; + getFemPostFilterPtr()->addFilterPipeline(pipe, name); + Py_Return; #else + (void)args; PyErr_SetString(PyExc_NotImplementedError, "VTK python wrapper not available"); - Py_Return; + return nullptr; #endif } PyObject* FemPostFilterPy::setActiveFilterPipeline(PyObject* args) { const char* name; - if (PyArg_ParseTuple(args, "s", &name)) { - getFemPostFilterPtr()->setActiveFilterPipeline(std::string(name)); + if (!PyArg_ParseTuple(args, "s", &name)) { + return nullptr; } + getFemPostFilterPtr()->setActiveFilterPipeline(std::string(name)); + Py_Return; } @@ -109,7 +114,7 @@ PyObject* FemPostFilterPy::getParentPostGroup(PyObject* args) return group->getPyObject(); } - return Py_None; + Py_Return; } PyObject* FemPostFilterPy::getInputData(PyObject* args) @@ -133,17 +138,18 @@ PyObject* FemPostFilterPy::getInputData(PyObject* args) default: PyErr_SetString(PyExc_TypeError, "cannot return datatype object; not unstructured grid"); - Py_Return; + return nullptr; } // return the python wrapper copy->DeepCopy(dataset); PyObject* py_dataset = vtkPythonUtil::GetObjectFromPointer(copy); - return Py::new_reference_to(py_dataset); + return py_dataset; #else + (void)args; PyErr_SetString(PyExc_NotImplementedError, "VTK python wrapper not available"); - Py_Return; + return nullptr; #endif } @@ -196,10 +202,11 @@ PyObject* FemPostFilterPy::getOutputAlgorithm(PyObject* args) auto algorithm = getFemPostFilterPtr()->getFilterOutput(); PyObject* py_algorithm = vtkPythonUtil::GetObjectFromPointer(algorithm); - return Py::new_reference_to(py_algorithm); + return py_algorithm; #else + (void)args; PyErr_SetString(PyExc_NotImplementedError, "VTK python wrapper not available"); - Py_Return; + return nullptr; #endif } diff --git a/src/Mod/Fem/App/FemPostObjectPyImp.cpp b/src/Mod/Fem/App/FemPostObjectPyImp.cpp index 50cd7184d9..95b6e2482e 100644 --- a/src/Mod/Fem/App/FemPostObjectPyImp.cpp +++ b/src/Mod/Fem/App/FemPostObjectPyImp.cpp @@ -69,12 +69,14 @@ PyObject* FemPostObjectPy::getDataSet(PyObject* args) auto dataset = getFemPostObjectPtr()->getDataSet(); if (dataset) { PyObject* py_algorithm = vtkPythonUtil::GetObjectFromPointer(dataset); - return Py::new_reference_to(py_algorithm); + return py_algorithm; } - return Py_None; -#else - PyErr_SetString(PyExc_NotImplementedError, "VTK python wrapper not available"); + Py_Return; +#else + (void)args; + PyErr_SetString(PyExc_NotImplementedError, "VTK python wrapper not available"); + return nullptr; #endif } diff --git a/src/Mod/Fem/App/FemPostPipelinePyImp.cpp b/src/Mod/Fem/App/FemPostPipelinePyImp.cpp index 556a0ca5f5..919952da01 100644 --- a/src/Mod/Fem/App/FemPostPipelinePyImp.cpp +++ b/src/Mod/Fem/App/FemPostPipelinePyImp.cpp @@ -327,10 +327,11 @@ PyObject* FemPostPipelinePy::getOutputAlgorithm(PyObject* args) auto algorithm = getFemPostPipelinePtr()->getOutputAlgorithm(); PyObject* py_algorithm = vtkPythonUtil::GetObjectFromPointer(algorithm); - return Py::new_reference_to(py_algorithm); + return py_algorithm; #else + (void)args; PyErr_SetString(PyExc_NotImplementedError, "VTK python wrapper not available"); - Py_Return; + return nullptr; #endif } diff --git a/src/Mod/Fem/Gui/ViewProviderFemPostFilterPyImp.cpp b/src/Mod/Fem/Gui/ViewProviderFemPostFilterPyImp.cpp index 9d4cb51253..e152d34d5d 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemPostFilterPyImp.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemPostFilterPyImp.cpp @@ -79,8 +79,9 @@ PyObject* ViewProviderFemPostFilterPy::createExtractionTaskWidget(PyObject* args PyErr_SetString(PyExc_TypeError, "creating the panel failed"); return nullptr; #else + (void)args; PyErr_SetString(PyExc_NotImplementedError, "VTK python wrapper not available"); - Py_Return; + return nullptr; #endif }