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 21, 2016
1 parent 82f7944 commit e8b3659
Show file tree
Hide file tree
Showing 20 changed files with 50 additions and 53 deletions.
3 changes: 0 additions & 3 deletions src/Mod/Part/App/Attacher.cpp
Expand Up @@ -733,9 +733,6 @@ GProp_GProps AttachEngine::getInertialPropsOfShape(const std::vector<const TopoD
default:
throw Base::Exception("AttachEngine::getInertialPropsOfShape: unexpected shape type");
}

assert(false);//exec shouldn't ever get here
return GProp_GProps();
}

/*!
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Part/App/FeatureExtrusion.cpp
Expand Up @@ -346,7 +346,7 @@ bool Extrusion::isInside(const TopoDS_Wire& wire1, const TopoDS_Wire& wire2) con
// because otherwise we have some intersections which is not allowed
else
return false;
xp.Next();
//xp.Next();
}

return false;
Expand Down
3 changes: 0 additions & 3 deletions src/Mod/Part/App/GeometryCurvePyImp.cpp
Expand Up @@ -464,9 +464,6 @@ PyObject* GeometryCurvePy::makeRuledSurface(PyObject *args)
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}

PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}

PyObject* GeometryCurvePy::intersect2d(PyObject *args)
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -2313,11 +2313,11 @@ struct MeshVertex
Standard_Integer i;

MeshVertex(Standard_Real X, Standard_Real Y, Standard_Real Z)
: x(X),y(Y),z(Z)
: x(X),y(Y),z(Z),i(0)
{
}
MeshVertex(const gp_Pnt& p)
: x(p.X()),y(p.Y()),z(p.Z())
: x(p.X()),y(p.Y()),z(p.Z()),i(0)
{
}

Expand Down
3 changes: 0 additions & 3 deletions src/Mod/Part/App/TopoShapeEdgePyImp.cpp
Expand Up @@ -624,9 +624,6 @@ PyObject* TopoShapeEdgePy::split(PyObject *args)
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}

PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}

PyObject* TopoShapeEdgePy::isSeam(PyObject *args)
Expand Down
5 changes: 2 additions & 3 deletions src/Mod/Part/App/TopoShapeFacePyImp.cpp
Expand Up @@ -683,10 +683,9 @@ Py::Object TopoShapeFacePy::getOuterWire(void) const
TopoDS_Wire clWire = ShapeAnalysis::OuterWire(clFace);
return Py::Object(new TopoShapeWirePy(new TopoShape(clWire)),true);
}
else
else {
throw Py::Exception("Internal error, TopoDS_Shape is not a face!");

return Py::Object();
}
}

Py::Object TopoShapeFacePy::getMass(void) const
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Part/Gui/DlgPrimitives.cpp
Expand Up @@ -683,6 +683,7 @@ void DlgPrimitives::createPrimitive(const QString& placement)

Location::Location(QWidget* parent)
{
mode = 0;
ui.setupUi(this);
}

Expand Down
1 change: 1 addition & 0 deletions src/Mod/Part/Gui/DlgRevolution.cpp
Expand Up @@ -65,6 +65,7 @@ class DlgRevolution::EdgeSelection : public Gui::SelectionFilterGate
EdgeSelection()
: Gui::SelectionFilterGate((Gui::SelectionFilter*)0)
{
canSelect = false;
}
bool allow(App::Document*pDoc, App::DocumentObject*pObj, const char*sSubName)
{
Expand Down
6 changes: 4 additions & 2 deletions src/Mod/Part/Gui/TaskDimension.cpp
Expand Up @@ -1232,8 +1232,10 @@ void PartGui::ArcEngine::defaultValues()
SO_ENGINE_OUTPUT(pointCount, SoSFInt32, setValue(2));
}

PartGui::SteppedSelection::SteppedSelection(const uint& buttonCountIn, QWidget* parent):
QWidget(parent)
PartGui::SteppedSelection::SteppedSelection(const uint& buttonCountIn, QWidget* parent)
: QWidget(parent)
, stepActive(0)
, stepDone(0)
{
if (buttonCountIn < 1)
return;
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/Part/Gui/ViewProviderCompound.cpp
Expand Up @@ -69,7 +69,7 @@ void ViewProviderCompound::updateData(const App::Property* prop)
if (prop->getTypeId() == Part::PropertyShapeHistory::getClassTypeId()) {
const std::vector<Part::ShapeHistory>& hist = static_cast<const Part::PropertyShapeHistory*>
(prop)->getValues();
Part::Compound* objComp = dynamic_cast<Part::Compound*>(getObject());
Part::Compound* objComp = static_cast<Part::Compound*>(getObject());
std::vector<App::DocumentObject*> sources = objComp->Links.getValues();
if (hist.size() != sources.size())
return;
Expand All @@ -85,6 +85,9 @@ void ViewProviderCompound::updateData(const App::Property* prop)
int index=0;
for (std::vector<App::DocumentObject*>::iterator it = sources.begin(); it != sources.end(); ++it, ++index) {
Part::Feature* objBase = dynamic_cast<Part::Feature*>(*it);
if (!objBase)
continue;

const TopoDS_Shape& baseShape = objBase->Shape.getValue();

TopTools_IndexedMapOfShape baseMap;
Expand Down
4 changes: 4 additions & 0 deletions src/Mod/Part/Gui/ViewProviderCurveNet.h
Expand Up @@ -68,6 +68,10 @@ class PartGuiExport ViewProviderCurveNet:public ViewProviderPart
struct Node {
Gui::SoFCSelection *pcHighlight;
SoTransform *pcTransform;
Node() {
pcHighlight = 0;
pcTransform = 0;
}
};

std::list<Node> NodeList;
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Part/Gui/ViewProviderMirror.cpp
Expand Up @@ -239,7 +239,7 @@ void ViewProviderFillet::updateData(const App::Property* prop)
return;
Part::Fillet* objFill = dynamic_cast<Part::Fillet*>(getObject());
Part::Feature* objBase = dynamic_cast<Part::Feature*>(objFill->Base.getValue());
if (objBase) {
if (objFill && objBase) {
const TopoDS_Shape& baseShape = objBase->Shape.getValue();
const TopoDS_Shape& fillShape = objFill->Shape.getValue();

Expand Down Expand Up @@ -342,7 +342,7 @@ void ViewProviderChamfer::updateData(const App::Property* prop)
return;
Part::Chamfer* objCham = dynamic_cast<Part::Chamfer*>(getObject());
Part::Feature* objBase = dynamic_cast<Part::Feature*>(objCham->Base.getValue());
if (objBase) {
if (objCham && objBase) {
const TopoDS_Shape& baseShape = objBase->Shape.getValue();
const TopoDS_Shape& chamShape = objCham->Shape.getValue();

Expand Down
2 changes: 0 additions & 2 deletions src/Mod/PartDesign/App/FeatureLoft.cpp
Expand Up @@ -212,8 +212,6 @@ App::DocumentObjectExecReturn *Loft::execute(void)
}

return App::DocumentObject::StdReturn;

return ProfileBased::execute();
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/PartDesign/App/FeatureMultiTransform.cpp
Expand Up @@ -80,9 +80,9 @@ const std::list<gp_Trsf> MultiTransform::getTransformations(const std::vector<Ap

if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
PartDesign::FeatureAddSub* addFeature = static_cast<PartDesign::FeatureAddSub*>(originalFeature);
if(addFeature->getAddSubType() == FeatureAddSub::Additive)
original = addFeature->AddSubShape.getShape().getShape();
else
//if (addFeature->getAddSubType() == FeatureAddSub::Additive)
// original = addFeature->AddSubShape.getShape().getShape();
//else
original = addFeature->AddSubShape.getShape().getShape();
}

Expand Down
4 changes: 1 addition & 3 deletions src/Mod/PartDesign/App/FeaturePipe.cpp
Expand Up @@ -317,10 +317,8 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
boolOp = refineShapeIfActive(boolOp);
Shape.setValue(getSolid(boolOp));
}

return App::DocumentObject::StdReturn;

return ProfileBased::execute();
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/PartDesign/App/FeatureScaled.cpp
Expand Up @@ -74,9 +74,9 @@ const std::list<gp_Trsf> Scaled::getTransformations(const std::vector<App::Docum

if (originalFeature->getTypeId().isDerivedFrom(PartDesign::FeatureAddSub::getClassTypeId())) {
PartDesign::FeatureAddSub* Feature = static_cast<PartDesign::FeatureAddSub*>(originalFeature);
if(Feature->getAddSubType() == FeatureAddSub::Additive)
original = Feature->AddSubShape.getShape().getShape();
else
//if(Feature->getAddSubType() == FeatureAddSub::Additive)
// original = Feature->AddSubShape.getShape().getShape();
//else
original = Feature->AddSubShape.getShape().getShape();
}

Expand Down
30 changes: 14 additions & 16 deletions src/Mod/PartDesign/Gui/Command.cpp
Expand Up @@ -726,29 +726,28 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which,

//if a profie is selected we can make our life easy and fast
auto selection = cmd->getSelection().getSelectionEx();
if(!selection.empty() && selection.front().hasSubNames()) {

if (!selection.empty() && selection.front().hasSubNames()) {
base_worker(selection.front().getObject(), selection.front().getSubNames().front());
return;
}

//no face profile was selected, do he extended sketch logic

bool bNoSketchWasSelected = false;
// Get a valid sketch from the user
// First check selections
std::vector<App::DocumentObject*> sketches = cmd->getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
if (sketches.size() == 0) {//no sketches were selected. Let user pick an object from valid ones available in document
if (sketches.empty()) {//no sketches were selected. Let user pick an object from valid ones available in document
sketches = cmd->getDocument()->getObjectsOfType(Part::Part2DObject::getClassTypeId());
bNoSketchWasSelected = true;
}

if(sketches.empty()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No sketch to work on"),
QObject::tr("No sketch is available in the document"));
return;
if (sketches.empty()) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No sketch to work on"),
QObject::tr("No sketch is available in the document"));
return;
}

std::vector<PartDesignGui::TaskFeaturePick::featureStatus> status;
std::vector<App::DocumentObject*>::iterator firstFreeSketch;
int freeSketches = validateSketches(sketches, status, firstFreeSketch);
Expand Down Expand Up @@ -778,7 +777,7 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which,

// TODO Clean this up (2015-10-20, Fat-Zer)
auto* pcActiveBody = PartDesignGui::getBody(false);
if(pcActiveBody && !bNoSketchWasSelected && ext) {
if (pcActiveBody && !bNoSketchWasSelected && ext) {

auto* pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);

Expand All @@ -805,7 +804,7 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which,

// Show sketch choose dialog and let user pick sketch if no sketch was selected and no free one available or
// multiple free ones are available
if ( bNoSketchWasSelected && (freeSketches != 1) ) {
if (bNoSketchWasSelected && (freeSketches != 1) ) {

Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast<PartDesignGui::TaskDlgFeaturePick *>(dlg);
Expand All @@ -827,21 +826,20 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which,

Gui::Selection().clearSelection();
pickDlg = new PartDesignGui::TaskDlgFeaturePick(sketches, status, accepter, sketch_worker);
if(!bNoSketchWasSelected && ext)
if (!bNoSketchWasSelected && ext)
pickDlg->showExternal(true);

Gui::Control().showDialog(pickDlg);
}
else {
std::vector<App::DocumentObject*> theSketch;
if(!bNoSketchWasSelected)
if (!bNoSketchWasSelected)
theSketch.push_back(sketches[0]);
else
theSketch.push_back(*firstFreeSketch);

sketch_worker(theSketch);
}

}

void finishProfileBased(const Gui::Command* cmd, const Part::Feature* sketch, const std::string& FeatName)
Expand Down
1 change: 0 additions & 1 deletion src/Mod/PartDesign/Gui/CommandBody.cpp
Expand Up @@ -666,7 +666,6 @@ void CmdPartDesignMoveFeature::activated(int iMsg)
bool CmdPartDesignMoveFeature::isActive(void)
{
return hasActiveDocument () && !PartDesignGui::isLegacyWorkflow ( getDocument () );
return hasActiveDocument ();
}

DEF_STD_CMD_A(CmdPartDesignMoveFeatureInTree);
Expand Down
5 changes: 2 additions & 3 deletions src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp
Expand Up @@ -177,10 +177,9 @@ void TaskBooleanParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
void TaskBooleanParameters::onButtonBodyAdd(bool checked)
{
if (checked) {
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (doc != NULL)
BooleanView->hide();
PartDesign::Boolean* pcBoolean = static_cast<PartDesign::Boolean*>(BooleanView->getObject());
Gui::Document* doc = BooleanView->getDocument();
BooleanView->hide();
if (pcBoolean->Bodies.getValues().empty() && pcBoolean->BaseFeature.getValue())
doc->setHide(pcBoolean->BaseFeature.getValue()->getNameInDocument());
selectionMode = bodyAdd;
Expand Down
8 changes: 6 additions & 2 deletions src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp
Expand Up @@ -51,8 +51,11 @@ TaskDressUpParameters::TaskDressUpParameters(ViewProviderDressUp *DressUpView, b
: TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + DressUpView->featureName()).c_str()),
QString::fromLatin1((DressUpView->featureName() + " parameters").c_str()),
true,
parent),
DressUpView(DressUpView), allowFaces(selectFaces), allowEdges(selectEdges)
parent)
, proxy(0)
, DressUpView(DressUpView)
, allowFaces(selectFaces)
, allowEdges(selectEdges)
{
selectionMode = none;
}
Expand Down Expand Up @@ -192,6 +195,7 @@ void TaskDressUpParameters::exitSelectionMode()

TaskDlgDressUpParameters::TaskDlgDressUpParameters(ViewProviderDressUp *DressUpView)
: TaskDlgFeatureParameters(DressUpView)
, parameter(0)
{
assert(DressUpView);
}
Expand Down

0 comments on commit e8b3659

Please sign in to comment.