Skip to content

Commit

Permalink
fix Coverity issues
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Aug 20, 2016
1 parent d80c05e commit d39bd49
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 122 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/App/AppSketcherPy.cpp
Expand Up @@ -77,7 +77,7 @@ class Module : public Py::ExtensionModule<Module>
throw Py::RuntimeError("No file extension");

throw Py::RuntimeError("Unknown file extension");
return Py::None();
//return Py::None();
}

Py::Object insert(const Py::Tuple& args)
Expand Down
38 changes: 19 additions & 19 deletions src/Mod/Sketcher/App/Sketch.cpp
Expand Up @@ -62,7 +62,7 @@ using namespace Part;
TYPESYSTEM_SOURCE(Sketcher::Sketch, Base::Persistence)

Sketch::Sketch()
: GCSsys(), ConstraintsCounter(0), isInitMove(false),
: SolveTime(0), GCSsys(), ConstraintsCounter(0), isInitMove(false), isFine(true),
defaultSolver(GCS::DogLeg),defaultSolverRedundant(GCS::DogLeg),debugMode(GCS::Minimal)
{
}
Expand Down Expand Up @@ -183,27 +183,27 @@ const char* nameByType(Sketch::GeoType type)
int Sketch::addGeometry(const Part::Geometry *geo, bool fixed)
{
if (geo->getTypeId() == GeomPoint::getClassTypeId()) { // add a point
const GeomPoint *point = dynamic_cast<const GeomPoint*>(geo);
const GeomPoint *point = static_cast<const GeomPoint*>(geo);
// create the definition struct for that geom
return addPoint(*point, fixed);
} else if (geo->getTypeId() == GeomLineSegment::getClassTypeId()) { // add a line
const GeomLineSegment *lineSeg = dynamic_cast<const GeomLineSegment*>(geo);
const GeomLineSegment *lineSeg = static_cast<const GeomLineSegment*>(geo);
// create the definition struct for that geom
return addLineSegment(*lineSeg, fixed);
} else if (geo->getTypeId() == GeomCircle::getClassTypeId()) { // add a circle
const GeomCircle *circle = dynamic_cast<const GeomCircle*>(geo);
const GeomCircle *circle = static_cast<const GeomCircle*>(geo);
// create the definition struct for that geom
return addCircle(*circle, fixed);
} else if (geo->getTypeId() == GeomEllipse::getClassTypeId()) { // add a ellipse
const GeomEllipse *ellipse = dynamic_cast<const GeomEllipse*>(geo);
const GeomEllipse *ellipse = static_cast<const GeomEllipse*>(geo);
// create the definition struct for that geom
return addEllipse(*ellipse, fixed);
} else if (geo->getTypeId() == GeomArcOfCircle::getClassTypeId()) { // add an arc
const GeomArcOfCircle *aoc = dynamic_cast<const GeomArcOfCircle*>(geo);
const GeomArcOfCircle *aoc = static_cast<const GeomArcOfCircle*>(geo);
// create the definition struct for that geom
return addArc(*aoc, fixed);
} else if (geo->getTypeId() == GeomArcOfEllipse::getClassTypeId()) { // add an arc
const GeomArcOfEllipse *aoe = dynamic_cast<const GeomArcOfEllipse*>(geo);
const GeomArcOfEllipse *aoe = static_cast<const GeomArcOfEllipse*>(geo);
// create the definition struct for that geom
return addArcOfEllipse(*aoe, fixed);
} else {
Expand Down Expand Up @@ -594,19 +594,19 @@ Py::Tuple Sketch::getPyGeometry(void) const
Base::Vector3d temp(*(Points[it->startPointId].x),*(Points[it->startPointId].y),0);
tuple[i] = Py::asObject(new VectorPy(temp));
} else if (it->type == Line) {
GeomLineSegment *lineSeg = dynamic_cast<GeomLineSegment*>(it->geo->clone());
GeomLineSegment *lineSeg = static_cast<GeomLineSegment*>(it->geo->clone());
tuple[i] = Py::asObject(new LinePy(lineSeg));
} else if (it->type == Arc) {
GeomArcOfCircle *aoc = dynamic_cast<GeomArcOfCircle*>(it->geo->clone());
GeomArcOfCircle *aoc = static_cast<GeomArcOfCircle*>(it->geo->clone());
tuple[i] = Py::asObject(new ArcOfCirclePy(aoc));
} else if (it->type == Circle) {
GeomCircle *circle = dynamic_cast<GeomCircle*>(it->geo->clone());
GeomCircle *circle = static_cast<GeomCircle*>(it->geo->clone());
tuple[i] = Py::asObject(new CirclePy(circle));
} else if (it->type == Ellipse) {
GeomEllipse *ellipse = dynamic_cast<GeomEllipse*>(it->geo->clone());
GeomEllipse *ellipse = static_cast<GeomEllipse*>(it->geo->clone());
tuple[i] = Py::asObject(new EllipsePy(ellipse));
} else if (it->type == ArcOfEllipse) {
GeomArcOfEllipse *ellipse = dynamic_cast<GeomArcOfEllipse*>(it->geo->clone());
GeomArcOfEllipse *ellipse = static_cast<GeomArcOfEllipse*>(it->geo->clone());
tuple[i] = Py::asObject(new ArcOfEllipsePy(ellipse));
}
else {
Expand Down Expand Up @@ -922,7 +922,7 @@ int Sketch::addConstraint(const Constraint *constraint)
c.value, c.secondvalue);
}
break;
case None:
case Sketcher::None: // ambiguous enum value
case NumConstraintTypes:
break;
}
Expand Down Expand Up @@ -1993,13 +1993,13 @@ bool Sketch::updateGeometry()
for (std::vector<GeoDef>::const_iterator it=Geoms.begin(); it != Geoms.end(); ++it, i++) {
try {
if (it->type == Point) {
GeomPoint *point = dynamic_cast<GeomPoint*>(it->geo);
GeomPoint *point = static_cast<GeomPoint*>(it->geo);
point->setPoint(Vector3d(*Points[it->startPointId].x,
*Points[it->startPointId].y,
0.0)
);
} else if (it->type == Line) {
GeomLineSegment *lineSeg = dynamic_cast<GeomLineSegment*>(it->geo);
GeomLineSegment *lineSeg = static_cast<GeomLineSegment*>(it->geo);
lineSeg->setPoints(Vector3d(*Lines[it->index].p1.x,
*Lines[it->index].p1.y,
0.0),
Expand All @@ -2014,7 +2014,7 @@ bool Sketch::updateGeometry()
// *myArc.start.y = *myArc.center.y + *myArc.rad * sin(*myArc.startAngle);
// *myArc.end.x = *myArc.center.x + *myArc.rad * cos(*myArc.endAngle);
// *myArc.end.y = *myArc.center.y + *myArc.rad * sin(*myArc.endAngle);
GeomArcOfCircle *aoc = dynamic_cast<GeomArcOfCircle*>(it->geo);
GeomArcOfCircle *aoc = static_cast<GeomArcOfCircle*>(it->geo);
aoc->setCenter(Vector3d(*Points[it->midPointId].x,
*Points[it->midPointId].y,
0.0)
Expand All @@ -2024,7 +2024,7 @@ bool Sketch::updateGeometry()
} else if (it->type == ArcOfEllipse) {
GCS::ArcOfEllipse &myArc = ArcsOfEllipse[it->index];

GeomArcOfEllipse *aoe = dynamic_cast<GeomArcOfEllipse*>(it->geo);
GeomArcOfEllipse *aoe = static_cast<GeomArcOfEllipse*>(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);
Expand All @@ -2044,15 +2044,15 @@ bool Sketch::updateGeometry()
aoe->setMajorAxisDir(fd);
aoe->setRange(*myArc.startAngle, *myArc.endAngle, /*emulateCCW=*/true);
} else if (it->type == Circle) {
GeomCircle *circ = dynamic_cast<GeomCircle*>(it->geo);
GeomCircle *circ = static_cast<GeomCircle*>(it->geo);
circ->setCenter(Vector3d(*Points[it->midPointId].x,
*Points[it->midPointId].y,
0.0)
);
circ->setRadius(*Circles[it->index].rad);
} else if (it->type == Ellipse) {

GeomEllipse *ellipse = dynamic_cast<GeomEllipse*>(it->geo);
GeomEllipse *ellipse = static_cast<GeomEllipse*>(it->geo);

Base::Vector3d center = Vector3d(*Points[it->midPointId].x, *Points[it->midPointId].y, 0.0);
Base::Vector3d f1 = Vector3d(*Ellipses[it->index].focus1.x, *Ellipses[it->index].focus1.y, 0.0);
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/Sketcher/App/Sketch.h
Expand Up @@ -348,7 +348,10 @@ class SketcherExport Sketch :public Base::Persistence
};
/// container element to store and work with the constraints of this sketch
struct ConstrDef {
ConstrDef() : driving(true) {}
ConstrDef() : constr(0)
, driving(true)
, value(0)
, secondvalue(0) {}
Constraint * constr; // pointer to the constraint
bool driving;
double * value;
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Sketcher/App/planegcs/GCS.cpp
Expand Up @@ -194,6 +194,7 @@ System::System()
, subSystems(0)
, subSystemsAux(0)
, reference(0)
, dofs(0)
, hasUnknowns(false)
, hasDiagnosis(false)
, isInit(false)
Expand Down
6 changes: 4 additions & 2 deletions src/Mod/Sketcher/Gui/Command.cpp
Expand Up @@ -605,8 +605,10 @@ void CmdSketcherViewSketch::activated(int iMsg)
{
Gui::Document *doc = getActiveGuiDocument();
SketcherGui::ViewProviderSketch* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
doCommand(Gui,"Gui.ActiveDocument.ActiveView.setCameraOrientation(App.ActiveDocument.%s.Placement.Rotation.Q)"
,vp->getObject()->getNameInDocument());
if (vp) {
doCommand(Gui,"Gui.ActiveDocument.ActiveView.setCameraOrientation(App.ActiveDocument.%s.Placement.Rotation.Q)"
,vp->getObject()->getNameInDocument());
}
}

bool CmdSketcherViewSketch::isActive(void)
Expand Down

0 comments on commit d39bd49

Please sign in to comment.