fix scan coverity issues: unchecked dynamic_cast
This commit is contained in:
@@ -231,7 +231,7 @@ int Sketch::addGeometry(const Part::Geometry *geo, bool fixed)
|
||||
// create the definition struct for that geom
|
||||
return addArcOfHyperbola(*aoh, fixed);
|
||||
} else if (geo->getTypeId() == GeomArcOfParabola::getClassTypeId()) { // add an arc of parabola
|
||||
const GeomArcOfParabola *aop = dynamic_cast<const GeomArcOfParabola*>(geo);
|
||||
const GeomArcOfParabola *aop = static_cast<const GeomArcOfParabola*>(geo);
|
||||
// create the definition struct for that geom
|
||||
return addArcOfParabola(*aop, fixed);
|
||||
} else if (geo->getTypeId() == GeomBSplineCurve::getClassTypeId()) { // add a bspline
|
||||
@@ -937,13 +937,13 @@ Py::Tuple Sketch::getPyGeometry(void) const
|
||||
GeomArcOfEllipse *ellipse = static_cast<GeomArcOfEllipse*>(it->geo->clone());
|
||||
tuple[i] = Py::asObject(new ArcOfEllipsePy(ellipse));
|
||||
} else if (it->type == ArcOfHyperbola) {
|
||||
GeomArcOfHyperbola *aoh = dynamic_cast<GeomArcOfHyperbola*>(it->geo->clone());
|
||||
GeomArcOfHyperbola *aoh = static_cast<GeomArcOfHyperbola*>(it->geo->clone());
|
||||
tuple[i] = Py::asObject(new ArcOfHyperbolaPy(aoh));
|
||||
} else if (it->type == ArcOfParabola) {
|
||||
GeomArcOfParabola *aop = dynamic_cast<GeomArcOfParabola*>(it->geo->clone());
|
||||
GeomArcOfParabola *aop = static_cast<GeomArcOfParabola*>(it->geo->clone());
|
||||
tuple[i] = Py::asObject(new ArcOfParabolaPy(aop));
|
||||
} else if (it->type == BSpline) {
|
||||
GeomBSplineCurve *bsp = dynamic_cast<GeomBSplineCurve*>(it->geo->clone());
|
||||
GeomBSplineCurve *bsp = static_cast<GeomBSplineCurve*>(it->geo->clone());
|
||||
tuple[i] = Py::asObject(new BSplineCurvePy(bsp));
|
||||
} else {
|
||||
// not implemented type in the sketch!
|
||||
@@ -2641,7 +2641,7 @@ bool Sketch::updateGeometry()
|
||||
} else if (it->type == ArcOfHyperbola) {
|
||||
GCS::ArcOfHyperbola &myArc = ArcsOfHyperbola[it->index];
|
||||
|
||||
GeomArcOfHyperbola *aoh = dynamic_cast<GeomArcOfHyperbola*>(it->geo);
|
||||
GeomArcOfHyperbola *aoh = static_cast<GeomArcOfHyperbola*>(it->geo);
|
||||
|
||||
Base::Vector3d center = Vector3d(*Points[it->midPointId].x, *Points[it->midPointId].y, 0.0);
|
||||
Base::Vector3d f1 = Vector3d(*myArc.focus1.x, *myArc.focus1.y, 0.0);
|
||||
@@ -2663,7 +2663,7 @@ bool Sketch::updateGeometry()
|
||||
} else if (it->type == ArcOfParabola) {
|
||||
GCS::ArcOfParabola &myArc = ArcsOfParabola[it->index];
|
||||
|
||||
GeomArcOfParabola *aop = dynamic_cast<GeomArcOfParabola*>(it->geo);
|
||||
GeomArcOfParabola *aop = static_cast<GeomArcOfParabola*>(it->geo);
|
||||
|
||||
Base::Vector3d vertex = Vector3d(*Points[it->midPointId].x, *Points[it->midPointId].y, 0.0);
|
||||
Base::Vector3d f1 = Vector3d(*myArc.focus1.x, *myArc.focus1.y, 0.0);
|
||||
@@ -2677,7 +2677,7 @@ bool Sketch::updateGeometry()
|
||||
} else if (it->type == BSpline) {
|
||||
GCS::BSpline &mybsp = BSplines[it->index];
|
||||
|
||||
GeomBSplineCurve *bsp = dynamic_cast<GeomBSplineCurve*>(it->geo);
|
||||
GeomBSplineCurve *bsp = static_cast<GeomBSplineCurve*>(it->geo);
|
||||
|
||||
std::vector<Base::Vector3d> poles;
|
||||
std::vector<double> weights;
|
||||
|
||||
@@ -520,7 +520,7 @@ Base::Vector3d SketchObject::getPoint(int GeoId, PointPos PosId) const
|
||||
else if (PosId == mid)
|
||||
return aoh->getCenter();
|
||||
} else if (geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) {
|
||||
const Part::GeomArcOfParabola *aop = dynamic_cast<const Part::GeomArcOfParabola*>(geo);
|
||||
const Part::GeomArcOfParabola *aop = static_cast<const Part::GeomArcOfParabola*>(geo);
|
||||
if (PosId == start)
|
||||
return aop->getStartPoint();
|
||||
else if (PosId == end)
|
||||
@@ -1050,7 +1050,7 @@ int SketchObject::fillet(int GeoId1, int GeoId2,
|
||||
}
|
||||
dist1.ProjectToLine(arc->getStartPoint(/*emulateCCW=*/true)-intersection, dir1);
|
||||
dist2.ProjectToLine(arc->getStartPoint(/*emulateCCW=*/true)-intersection, dir2);
|
||||
Part::Geometry *newgeo = dynamic_cast<Part::Geometry* >(arc);
|
||||
Part::Geometry *newgeo = arc;
|
||||
filletId = addGeometry(newgeo);
|
||||
if (filletId < 0) {
|
||||
delete arc;
|
||||
@@ -1937,7 +1937,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
}
|
||||
else { // trim arc end
|
||||
delConstraintOnPoint(GeoId, end, false);
|
||||
Part::GeomArcOfHyperbola *aoe1 = dynamic_cast<Part::GeomArcOfHyperbola*>(geomlist[GeoId]);
|
||||
Part::GeomArcOfHyperbola *aoe1 = static_cast<Part::GeomArcOfHyperbola*>(geomlist[GeoId]);
|
||||
aoe1->setRange(startAngle, startAngle + theta1, /*emulateCCW=*/true);
|
||||
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
|
||||
newConstr->Type = constrType;
|
||||
|
||||
@@ -228,7 +228,7 @@ void SketcherValidation::on_findButton_clicked()
|
||||
vertexIds.push_back(id);
|
||||
}
|
||||
else if (g->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) {
|
||||
const Part::GeomArcOfParabola *segm = dynamic_cast<const Part::GeomArcOfParabola*>(g);
|
||||
const Part::GeomArcOfParabola *segm = static_cast<const Part::GeomArcOfParabola*>(g);
|
||||
VertexIds id;
|
||||
id.GeoId = (int)i;
|
||||
id.PosId = Sketcher::start;
|
||||
|
||||
@@ -2293,7 +2293,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
||||
|
||||
} else if ((*it)->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) {
|
||||
// Check if arc lies inside box selection
|
||||
const Part::GeomArcOfParabola *aop = dynamic_cast<const Part::GeomArcOfParabola *>(*it);
|
||||
const Part::GeomArcOfParabola *aop = static_cast<const Part::GeomArcOfParabola *>(*it);
|
||||
|
||||
pnt0 = aop->getStartPoint();
|
||||
pnt1 = aop->getEndPoint();
|
||||
@@ -4112,7 +4112,7 @@ Restart:
|
||||
angle1plus = (startangle + endangle)/2;
|
||||
midpos1 = aoe->getCenter();
|
||||
} else if (geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) {
|
||||
const Part::GeomArcOfHyperbola *aoh = dynamic_cast<const Part::GeomArcOfHyperbola *>(geo1);
|
||||
const Part::GeomArcOfHyperbola *aoh = static_cast<const Part::GeomArcOfHyperbola *>(geo1);
|
||||
r1a = aoh->getMajorRadius();
|
||||
r1b = aoh->getMinorRadius();
|
||||
double startangle, endangle;
|
||||
@@ -4122,7 +4122,7 @@ Restart:
|
||||
angle1plus = (startangle + endangle)/2;
|
||||
midpos1 = aoh->getCenter();
|
||||
} else if (geo1->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) {
|
||||
const Part::GeomArcOfParabola *aop = dynamic_cast<const Part::GeomArcOfParabola *>(geo1);
|
||||
const Part::GeomArcOfParabola *aop = static_cast<const Part::GeomArcOfParabola *>(geo1);
|
||||
r1a = aop->getFocal();
|
||||
double startangle, endangle;
|
||||
aop->getRange(startangle, endangle, /*emulateCCW=*/true);
|
||||
@@ -4174,7 +4174,7 @@ Restart:
|
||||
angle2plus = (startangle + endangle)/2;
|
||||
midpos2 = aoh->getCenter();
|
||||
} else if (geo2->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) {
|
||||
const Part::GeomArcOfParabola *aop = dynamic_cast<const Part::GeomArcOfParabola *>(geo2);
|
||||
const Part::GeomArcOfParabola *aop = static_cast<const Part::GeomArcOfParabola *>(geo2);
|
||||
r2a = aop->getFocal();
|
||||
double startangle, endangle;
|
||||
aop->getRange(startangle, endangle, /*emulateCCW=*/true);
|
||||
|
||||
@@ -175,6 +175,9 @@ void CmdTechDrawNewGeomHatch::activated(int iMsg)
|
||||
geomhatch->Source.setValue(objFeat, subNames);
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getDocument(getDocument())->getViewProvider(geomhatch);
|
||||
TechDrawGui::ViewProviderGeomHatch* hvp = dynamic_cast<TechDrawGui::ViewProviderGeomHatch*>(vp);
|
||||
if( hvp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
// if (!hvp) {
|
||||
|
||||
// dialog to fill in hatch values
|
||||
|
||||
@@ -115,6 +115,8 @@ void QGIViewImage::draw()
|
||||
}
|
||||
|
||||
auto viewImage( dynamic_cast<TechDraw::DrawViewImage*>(getViewObject()) );
|
||||
if (!viewImage)
|
||||
return;
|
||||
QRectF newRect(0.0,0.0,Rez::guiX(viewImage->Width.getValue()),Rez::guiX(viewImage->Height.getValue()));
|
||||
double pad = Rez::guiX(1.0);
|
||||
m_cliparea->setRect(newRect.adjusted(-pad,-pad,pad,pad));
|
||||
|
||||
Reference in New Issue
Block a user