fix Coverity issues

This commit is contained in:
wmayer 2016-08-20 15:41:33 +02:00
parent de7978434d
commit f3f0f5bd2e
10 changed files with 22 additions and 20 deletions

View File

@ -102,7 +102,7 @@ App::DocumentObjectExecReturn *FeatureClip::execute(void)
const std::vector<App::DocumentObject*> &Grp = Group.getValues(); const std::vector<App::DocumentObject*> &Grp = Group.getValues();
for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) { for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
if ((*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) { if ((*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId())) {
Drawing::FeatureView *View = dynamic_cast<Drawing::FeatureView *>(*It); Drawing::FeatureView *View = static_cast<Drawing::FeatureView *>(*It);
svg << View->ViewResult.getValue() << endl; svg << View->ViewResult.getValue() << endl;
} }
} }

View File

@ -168,24 +168,24 @@ App::DocumentObjectExecReturn *FeaturePage::execute(void)
const std::vector<App::DocumentObject*> &Grp = Group.getValues(); const std::vector<App::DocumentObject*> &Grp = Group.getValues();
for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) { for (std::vector<App::DocumentObject*>::const_iterator It= Grp.begin();It!=Grp.end();++It) {
if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) { if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) {
Drawing::FeatureView *View = dynamic_cast<Drawing::FeatureView *>(*It); Drawing::FeatureView *View = static_cast<Drawing::FeatureView *>(*It);
if (View->Visible.getValue()) { if (View->Visible.getValue()) {
ofile << View->ViewResult.getValue(); ofile << View->ViewResult.getValue();
ofile << tempendl << tempendl << tempendl; ofile << tempendl << tempendl << tempendl;
} }
} else if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId()) ) { } else if ( (*It)->getTypeId().isDerivedFrom(Drawing::FeatureClip::getClassTypeId()) ) {
Drawing::FeatureClip *Clip = dynamic_cast<Drawing::FeatureClip *>(*It); Drawing::FeatureClip *Clip = static_cast<Drawing::FeatureClip *>(*It);
if (Clip->Visible.getValue()) { if (Clip->Visible.getValue()) {
ofile << Clip->ViewResult.getValue(); ofile << Clip->ViewResult.getValue();
ofile << tempendl << tempendl << tempendl; ofile << tempendl << tempendl << tempendl;
} }
} else if ( (*It)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()) ) { } else if ( (*It)->getTypeId().isDerivedFrom(App::DocumentObjectGroup::getClassTypeId()) ) {
// getting children inside subgroups too // getting children inside subgroups too
App::DocumentObjectGroup *SubGroup = dynamic_cast<App::DocumentObjectGroup *>(*It); App::DocumentObjectGroup *SubGroup = static_cast<App::DocumentObjectGroup *>(*It);
const std::vector<App::DocumentObject*> &SubGrp = SubGroup->Group.getValues(); const std::vector<App::DocumentObject*> &SubGrp = SubGroup->Group.getValues();
for (std::vector<App::DocumentObject*>::const_iterator Grit= SubGrp.begin();Grit!=SubGrp.end();++Grit) { for (std::vector<App::DocumentObject*>::const_iterator Grit= SubGrp.begin();Grit!=SubGrp.end();++Grit) {
if ( (*Grit)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) { if ( (*Grit)->getTypeId().isDerivedFrom(Drawing::FeatureView::getClassTypeId()) ) {
Drawing::FeatureView *SView = dynamic_cast<Drawing::FeatureView *>(*Grit); Drawing::FeatureView *SView = static_cast<Drawing::FeatureView *>(*Grit);
if (SView->Visible.getValue()) { if (SView->Visible.getValue()) {
ofile << SView->ViewResult.getValue(); ofile << SView->ViewResult.getValue();
ofile << tempendl << tempendl << tempendl; ofile << tempendl << tempendl << tempendl;

View File

@ -302,8 +302,6 @@ Py::Object StdMeshers_AutomaticLengthPy::getLength(const Py::Tuple& args)
const TopoDS_Shape& s = shape.extensionObject()->getTopoShapePtr()->getShape(); const TopoDS_Shape& s = shape.extensionObject()->getTopoShapePtr()->getShape();
return Py::Float(hypothesis<StdMeshers_AutomaticLength>()->GetLength(m->getSMesh(),s)); return Py::Float(hypothesis<StdMeshers_AutomaticLength>()->GetLength(m->getSMesh(),s));
} }
throw Py::Exception();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -872,7 +872,7 @@ void DefineNodesCallback(void * ud, SoEventCallback * n)
if(docObj.size() !=1) if(docObj.size() !=1)
return; return;
const SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(dynamic_cast<Fem::FemMeshObject*>(docObj[0])->FemMesh.getValue().getSMesh())->GetMeshDS(); const SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(static_cast<Fem::FemMeshObject*>(docObj[0])->FemMesh.getValue().getSMesh())->GetMeshDS();
SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator(); SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator();
Base::Vector3f pt2d; Base::Vector3f pt2d;

View File

@ -55,9 +55,10 @@ TaskDlgMeshShapeNetgen::TaskDlgMeshShapeNetgen(FemGui::ViewProviderFemMeshShapeN
: TaskDialog(),ViewProviderFemMeshShapeNetgen(obj) : TaskDialog(),ViewProviderFemMeshShapeNetgen(obj)
{ {
FemMeshShapeNetgenObject = dynamic_cast<Fem::FemMeshShapeNetgenObject *>(obj->getObject()); FemMeshShapeNetgenObject = dynamic_cast<Fem::FemMeshShapeNetgenObject *>(obj->getObject());
param = new TaskTetParameter(FemMeshShapeNetgenObject); if (FemMeshShapeNetgenObject) {
param = new TaskTetParameter(FemMeshShapeNetgenObject);
Content.push_back(param); Content.push_back(param);
}
} }
TaskDlgMeshShapeNetgen::~TaskDlgMeshShapeNetgen() TaskDlgMeshShapeNetgen::~TaskDlgMeshShapeNetgen()

View File

@ -473,7 +473,7 @@ std::vector<Base::Vector3d> ViewProviderFemMesh::getSelectionShape(const char* E
void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNodes) void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNodes)
{ {
if(!HighlightedNodes.empty()){ if(!HighlightedNodes.empty()){
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((dynamic_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh).getValue().getSMesh())->GetMeshDS(); SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((static_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh).getValue().getSMesh())->GetMeshDS();
pcAnoCoords->point.setNum(HighlightedNodes.size()); pcAnoCoords->point.setNum(HighlightedNodes.size());
SbVec3f* verts = pcAnoCoords->point.startEditing(); SbVec3f* verts = pcAnoCoords->point.startEditing();
@ -685,7 +685,7 @@ void ViewProviderFEMMeshBuilder::buildNodes(const App::Property* prop, std::vect
pcFaces = static_cast<SoIndexedFaceSet*>(nodes[1]); pcFaces = static_cast<SoIndexedFaceSet*>(nodes[1]);
} }
if (pcPointsCoord && pcFaces){ if (pcPointsCoord && pcFaces && pcLines){
std::vector<unsigned long> vFaceElementIdx; std::vector<unsigned long> vFaceElementIdx;
std::vector<unsigned long> vNodeElementIdx; std::vector<unsigned long> vNodeElementIdx;
bool onlyEdges; bool onlyEdges;

View File

@ -224,7 +224,7 @@ Py::List ViewProviderFemMeshPy::getHighlightedNodes(void) const
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg) void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
{ {
ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr(); ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr();
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((dynamic_cast<Fem::FemMeshObject*> SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((static_cast<Fem::FemMeshObject*>
(vp->getObject())->FemMesh).getValue().getSMesh())->GetMeshDS(); (vp->getObject())->FemMesh).getValue().getSMesh())->GetMeshDS();
std::set<long> res; std::set<long> res;

View File

@ -37,7 +37,7 @@ PROPERTY_SOURCE(FemGui::ViewProviderSetNodes, Gui::ViewProviderGeometryObject)
bool ViewProviderSetNodes::doubleClicked(void) bool ViewProviderSetNodes::doubleClicked(void)
{ {
Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast<Fem::FemSetNodesObject *>(getObject())); Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(static_cast<Fem::FemSetNodesObject *>(getObject()));
Gui::Control().showDialog(dlg); Gui::Control().showDialog(dlg);
return true; return true;
} }
@ -45,7 +45,7 @@ bool ViewProviderSetNodes::doubleClicked(void)
bool ViewProviderSetNodes::setEdit(int ModNum) bool ViewProviderSetNodes::setEdit(int ModNum)
{ {
Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(dynamic_cast<Fem::FemSetNodesObject *>(getObject())); Gui::TaskView::TaskDialog* dlg = new TaskDlgCreateNodeSet(static_cast<Fem::FemSetNodesObject *>(getObject()));
Gui::Control().showDialog(dlg); Gui::Control().showDialog(dlg);
return true; return true;
} }

View File

@ -1532,7 +1532,6 @@ private:
#else #else
throw Py::RuntimeError("FreeCAD compiled without FreeType support! This method is disabled..."); throw Py::RuntimeError("FreeCAD compiled without FreeType support! This method is disabled...");
#endif #endif
return Py::None();
} }
Py::Object exportUnits(const Py::Tuple& args) Py::Object exportUnits(const Py::Tuple& args)
{ {

View File

@ -88,7 +88,7 @@ void ViewProviderBoolean::updateData(const App::Property* prop)
Part::Boolean* objBool = dynamic_cast<Part::Boolean*>(getObject()); Part::Boolean* objBool = dynamic_cast<Part::Boolean*>(getObject());
Part::Feature* objBase = dynamic_cast<Part::Feature*>(objBool->Base.getValue()); Part::Feature* objBase = dynamic_cast<Part::Feature*>(objBool->Base.getValue());
Part::Feature* objTool = dynamic_cast<Part::Feature*>(objBool->Tool.getValue()); Part::Feature* objTool = dynamic_cast<Part::Feature*>(objBool->Tool.getValue());
if (objBase && objTool) { if (objBool && objBase && objTool) {
const TopoDS_Shape& baseShape = objBase->Shape.getValue(); const TopoDS_Shape& baseShape = objBase->Shape.getValue();
const TopoDS_Shape& toolShape = objTool->Shape.getValue(); const TopoDS_Shape& toolShape = objTool->Shape.getValue();
const TopoDS_Shape& boolShape = objBool->Shape.getValue(); const TopoDS_Shape& boolShape = objBool->Shape.getValue();
@ -176,7 +176,7 @@ void ViewProviderMultiFuse::updateData(const App::Property* prop)
if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) {
const std::vector<Part::ShapeHistory>& hist = static_cast<const Part::PropertyShapeHistory*> const std::vector<Part::ShapeHistory>& hist = static_cast<const Part::PropertyShapeHistory*>
(prop)->getValues(); (prop)->getValues();
Part::MultiFuse* objBool = dynamic_cast<Part::MultiFuse*>(getObject()); Part::MultiFuse* objBool = static_cast<Part::MultiFuse*>(getObject());
std::vector<App::DocumentObject*> sources = objBool->Shapes.getValues(); std::vector<App::DocumentObject*> sources = objBool->Shapes.getValues();
if (hist.size() != sources.size()) if (hist.size() != sources.size())
return; return;
@ -192,6 +192,8 @@ void ViewProviderMultiFuse::updateData(const App::Property* prop)
int index=0; int index=0;
for (std::vector<App::DocumentObject*>::iterator it = sources.begin(); it != sources.end(); ++it, ++index) { for (std::vector<App::DocumentObject*>::iterator it = sources.begin(); it != sources.end(); ++it, ++index) {
Part::Feature* objBase = dynamic_cast<Part::Feature*>(*it); Part::Feature* objBase = dynamic_cast<Part::Feature*>(*it);
if (!objBase)
continue;
const TopoDS_Shape& baseShape = objBase->Shape.getValue(); const TopoDS_Shape& baseShape = objBase->Shape.getValue();
TopTools_IndexedMapOfShape baseMap; TopTools_IndexedMapOfShape baseMap;
@ -293,7 +295,7 @@ void ViewProviderMultiCommon::updateData(const App::Property* prop)
if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) { if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) {
const std::vector<Part::ShapeHistory>& hist = static_cast<const Part::PropertyShapeHistory*> const std::vector<Part::ShapeHistory>& hist = static_cast<const Part::PropertyShapeHistory*>
(prop)->getValues(); (prop)->getValues();
Part::MultiCommon* objBool = dynamic_cast<Part::MultiCommon*>(getObject()); Part::MultiCommon* objBool = static_cast<Part::MultiCommon*>(getObject());
std::vector<App::DocumentObject*> sources = objBool->Shapes.getValues(); std::vector<App::DocumentObject*> sources = objBool->Shapes.getValues();
if (hist.size() != sources.size()) if (hist.size() != sources.size())
return; return;
@ -309,6 +311,8 @@ void ViewProviderMultiCommon::updateData(const App::Property* prop)
int index=0; int index=0;
for (std::vector<App::DocumentObject*>::iterator it = sources.begin(); it != sources.end(); ++it, ++index) { for (std::vector<App::DocumentObject*>::iterator it = sources.begin(); it != sources.end(); ++it, ++index) {
Part::Feature* objBase = dynamic_cast<Part::Feature*>(*it); Part::Feature* objBase = dynamic_cast<Part::Feature*>(*it);
if (!objBase)
continue;
const TopoDS_Shape& baseShape = objBase->Shape.getValue(); const TopoDS_Shape& baseShape = objBase->Shape.getValue();
TopTools_IndexedMapOfShape baseMap; TopTools_IndexedMapOfShape baseMap;