diff --git a/src/App/ExtensionContainer.cpp b/src/App/ExtensionContainer.cpp index cbc203a76b..8950db6d78 100644 --- a/src/App/ExtensionContainer.cpp +++ b/src/App/ExtensionContainer.cpp @@ -95,19 +95,25 @@ bool ExtensionContainer::hasExtension(const std::string& name) const { Extension* ExtensionContainer::getExtension(Base::Type t, bool derived) const { - + auto result = _extensions.find(t); if((result == _extensions.end()) && derived) { //we need to check for derived types - for(auto entry : _extensions) { + for(auto entry : _extensions) { if(entry.first.isDerivedFrom(t)) return entry.second; } - //if we arive hear we don't have anything matching + + //if we arrive here we don't have anything matching + throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available"); + } + else if (result != _extensions.end()) { + return result->second; + } + else { + //if we arrive here we don't have anything matching throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available"); } - - return result->second; } bool ExtensionContainer::hasExtensions() const { diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 05fe939a20..06f714fe9e 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -235,6 +235,7 @@ std::string InterpreterSingleton::runString(const char *sCmd) throw SystemExitException(); else { PyException::ThrowException(); + return std::string(); // just to quieten code analyzers //throw PyException(); } } diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 2010dbfcab..dc1377c52b 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -774,7 +774,11 @@ void Application::onLastWindowClosed(Gui::Document* pcDoc) // Call the closing mechanism from Python. This also checks whether pcDoc is the last open document. Command::doCommand(Command::Doc, "App.closeDocument(\"%s\")", pcDoc->getDocument()->getName()); } - catch (const Base::PyException& e) { + catch (const Base::Exception& e) { + e.ReportException(); + } + catch (const Py::Exception&) { + Base::PyException e; e.ReportException(); } } diff --git a/src/Gui/GraphvizView.cpp b/src/Gui/GraphvizView.cpp index f8e036cdb1..e318b457ae 100644 --- a/src/Gui/GraphvizView.cpp +++ b/src/Gui/GraphvizView.cpp @@ -221,7 +221,8 @@ void GraphvizView::updateSvgItem(const App::Document &doc) flatProc->setEnvironment(QProcess::systemEnvironment()); do { flatProc->start(unflatten, flatArgs); - flatProc->waitForStarted(); + bool value = flatProc->waitForStarted(); + Q_UNUSED(value); // quieten code analyzer dotProc->start(dot, args); if (!dotProc->waitForStarted()) { int ret = QMessageBox::warning(Gui::getMainWindow(), diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp index 9e3aa1ce0b..3053a76c36 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp @@ -127,6 +127,7 @@ void initComboBox(QComboBox* combo, const std::vector& textItems, c /* TRANSLATOR FemGui::TaskFemConstraintFluidBoundary */ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(ViewProviderFemConstraintFluidBoundary *ConstraintView,QWidget *parent) : TaskFemConstraint(ConstraintView, parent, "fem-constraint-fluid-boundary") + , dimension(-1) { // we need a separate container widget to add all controls to proxy = new QWidget(this); diff --git a/src/Mod/Import/App/ImportOCAF.cpp b/src/Mod/Import/App/ImportOCAF.cpp index f8c52fe46f..6d118b5faa 100644 --- a/src/Mod/Import/App/ImportOCAF.cpp +++ b/src/Mod/Import/App/ImportOCAF.cpp @@ -110,7 +110,7 @@ using namespace Import; #define OCAF_KEEP_PLACEMENT ImportOCAF::ImportOCAF(Handle(TDocStd_Document) h, App::Document* d, const std::string& name) - : pDoc(h), doc(d), default_name(name) + : pDoc(h), doc(d), merge(true), default_name(name) { aShapeTool = XCAFDoc_DocumentTool::ShapeTool (pDoc->Main()); aColorTool = XCAFDoc_DocumentTool::ColorTool(pDoc->Main()); diff --git a/src/Mod/Part/Gui/TaskAttacher.cpp b/src/Mod/Part/Gui/TaskAttacher.cpp index a751027b09..89f177db66 100644 --- a/src/Mod/Part/Gui/TaskAttacher.cpp +++ b/src/Mod/Part/Gui/TaskAttacher.cpp @@ -876,7 +876,11 @@ void TaskAttacher::visibilityAutomation(bool opening_not_closing) ).toLatin1(); Base::Interpreter().runString(code_2.constData()); } - catch (Base::Exception &e){ + catch (const Base::Exception &e){ + e.ReportException(); + } + catch (const Py::Exception&) { + Base::PyException e; e.ReportException(); } } diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index deb9614136..88f821f61f 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -493,6 +493,10 @@ void Hole::updateHoleCutParams() if (threadType == "ISOMetricProfile" || threadType == "ISOMetricFineProfile") { std::string holeCutType = HoleCutType.getValueAsString(); + if (ThreadType.getValue() < 0) + throw Base::IndexError("Thread type out of range"); + if (ThreadSize.getValue() < 0) + throw Base::IndexError("Thread size out of range"); double diameter = PartDesign::Hole::threadDescription[ThreadType.getValue()][ThreadSize.getValue()].diameter; double f = 1.0; double depth = 0; @@ -528,6 +532,10 @@ void Hole::updateDiameterParam() int threadType = ThreadType.getValue(); int threadSize = ThreadSize.getValue(); + if (threadType < 0) + throw Base::IndexError("Thread type out of range"); + if (threadSize < 0) + throw Base::IndexError("Thread size out of range"); double diameter = threadDescription[threadType][threadSize].diameter; double pitch = threadDescription[threadType][threadSize].pitch; diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 13a216f5aa..465def011e 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -280,6 +281,15 @@ std::vector TaskFeaturePick::buildFeatures() catch (const Base::Exception& e) { e.ReportException(); } + catch (Py::Exception& e) { + // reported by code analyzers + e.clear(); + Base::Console().Warning("Unexpected PyCXX exception\n"); + } + catch (const boost::exception&) { + // reported by code analyzers + Base::Console().Warning("Unexpected boost exception\n"); + } return result; } diff --git a/src/Mod/PartDesign/Gui/Utils.cpp b/src/Mod/PartDesign/Gui/Utils.cpp index 2fff0a4925..6cd5153fe1 100644 --- a/src/Mod/PartDesign/Gui/Utils.cpp +++ b/src/Mod/PartDesign/Gui/Utils.cpp @@ -63,10 +63,10 @@ PartDesign::Body *getBody(bool messageIfNot) { PartDesign::Body * activeBody = nullptr; Gui::MDIView *activeView = Gui::Application::Instance->activeView(); - bool singleBodyDocument = activeView->getAppDocument()-> - countObjectsOfType(PartDesign::Body::getClassTypeId()) == 1; if (activeView) { + bool singleBodyDocument = activeView->getAppDocument()-> + countObjectsOfType(PartDesign::Body::getClassTypeId()) == 1; if ( PartDesignGui::assureModernWorkflow ( activeView->getAppDocument() ) ) { activeBody = activeView->getActiveObject(PDBODYKEY); diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index 042bb84d71..971ad7a43e 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -159,6 +159,7 @@ Area::Area(const AreaParams *params) ,myHaveSolid(false) ,myShapeDone(false) ,myProjecting(false) +,mySkippedShapes(0) { if(params) setParams(*params); @@ -174,6 +175,7 @@ Area::Area(const Area &other, bool deep_copy) ,myHaveSolid(other.myHaveSolid) ,myShapeDone(false) ,myProjecting(false) +,mySkippedShapes(0) { if(!deep_copy || !other.isBuilt()) return; @@ -2226,12 +2228,26 @@ struct ShapeInfo{ bool myStart; ShapeInfo(BRepLib_FindSurface &finder, const TopoDS_Shape &shape, ShapeParams ¶ms) - :myPln(GeomAdaptor_Surface(finder.Surface()).Plane()) - ,myShape(shape),myStartPt(1e20,1e20,1e20),myParams(params),myPlanar(true) + : myPln(GeomAdaptor_Surface(finder.Surface()).Plane()) + , myShape(shape) + , myStartPt(1e20,1e20,1e20) + , myParams(params) + , myBestParameter(0) + , mySupportEdge(false) + , myPlanar(true) + , myRebase(false) + , myStart(false) {} ShapeInfo(const TopoDS_Shape &shape, ShapeParams ¶ms) - :myShape(shape),myStartPt(1e20,1e20,1e20),myParams(params),myPlanar(false) + : myShape(shape) + , myStartPt(1e20,1e20,1e20) + , myParams(params) + , myBestParameter(0) + , mySupportEdge(false) + , myPlanar(false) + , myRebase(false) + , myStart(false) {} double nearest(const gp_Pnt &pt) { myStartPt = pt; diff --git a/src/Mod/Path/App/Tooltable.cpp b/src/Mod/Path/App/Tooltable.cpp index 6efe81b682..195ebf9509 100644 --- a/src/Mod/Path/App/Tooltable.cpp +++ b/src/Mod/Path/App/Tooltable.cpp @@ -51,7 +51,7 @@ Tool::Tool(const char* name, double cornerradius, double cuttingedgeangle, double cuttingedgeheight) -:Name(name),Type(type),Diameter(diameter),LengthOffset(lengthoffset), +:Name(name),Type(type),Material(MATUNDEFINED),Diameter(diameter),LengthOffset(lengthoffset), FlatRadius(flatradius),CornerRadius(cornerradius),CuttingEdgeAngle(cuttingedgeangle), CuttingEdgeHeight(cuttingedgeheight) { @@ -59,6 +59,14 @@ CuttingEdgeHeight(cuttingedgeheight) Tool::Tool() { + Type = UNDEFINED; + Material = MATUNDEFINED; + Diameter = 0; + LengthOffset = 0; + FlatRadius = 0; + CornerRadius = 0; + CuttingEdgeAngle = 0; + CuttingEdgeHeight = 0; } Tool::~Tool() diff --git a/src/Mod/Path/Gui/ViewProviderPath.cpp b/src/Mod/Path/Gui/ViewProviderPath.cpp index de41561641..f26f2f4988 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.cpp +++ b/src/Mod/Path/Gui/ViewProviderPath.cpp @@ -77,7 +77,7 @@ using namespace PartGui; PROPERTY_SOURCE(PathGui::ViewProviderPath, Gui::ViewProviderGeometryObject) ViewProviderPath::ViewProviderPath() - :pt0Index(-1),blockPropertyChange(false),edgeStart(-1),coordStart(-1) + :pt0Index(-1),blockPropertyChange(false),edgeStart(-1),coordStart(-1),coordEnd(-1) { ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Path"); unsigned long lcol = hGrp->GetUnsigned("DefaultNormalPathColor",11141375UL); // dark green (0,170,0) diff --git a/src/Mod/Path/libarea/Area.h b/src/Mod/Path/libarea/Area.h index 88e8fca5cf..6c0bced98d 100644 --- a/src/Mod/Path/libarea/Area.h +++ b/src/Mod/Path/libarea/Area.h @@ -34,6 +34,7 @@ struct CAreaPocketParams from_center = From_center; mode = Mode; zig_angle = Zig_angle; + only_cut_first_offset = false; } }; diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 5c1aedaedd..f9c3da107a 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -5802,7 +5802,8 @@ int SketchObject::changeConstraintsLocking(bool bLock) /*! - * \brief SketchObject::port_reversedExternalArcs finds constraints that link to endpoints of external-geometry arcs, and swaps the endpoints in the constraints. This is needed after CCW emulation was introduced, to port old sketches. + * \brief SketchObject::port_reversedExternalArcs finds constraints that link to endpoints of external-geometry arcs, + * and swaps the endpoints in the constraints. This is needed after CCW emulation was introduced, to port old sketches. * \param justAnalyze if true, nothing is actually done - only the number of constraints to be affected is returned. * \return the number of constraints changed/to be changed. */ @@ -5819,8 +5820,8 @@ int SketchObject::port_reversedExternalArcs(bool justAnalyze) bool affected=false; Constraint *constNew = 0; for(int ig=1; ig<=3; ig++){//cycle through constraint.first, second, third - int geoId; - Sketcher::PointPos posId; + int geoId = 0; + Sketcher::PointPos posId = none; switch (ig){ case 1: geoId=newVals[ic]->First; posId = newVals[ic]->FirstPos; break; case 2: geoId=newVals[ic]->Second; posId = newVals[ic]->SecondPos; break; diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index f5adf119bb..b9d6f33278 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -6030,6 +6030,7 @@ public: , EditCurve(2) , BaseGeoId(-1) , ExtendFromStart(false) + , Increment(0) { } virtual ~DrawSketchHandlerExtend() diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 383bac816b..c3add8f9ee 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3380,7 +3380,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer Points.push_back(center); } else if ((*it)->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { - const Part::GeomArcOfHyperbola *aoh = dynamic_cast(*it); + const Part::GeomArcOfHyperbola *aoh = static_cast(*it); Handle(Geom_TrimmedCurve) curve = Handle(Geom_TrimmedCurve)::DownCast(aoh->handle()); double startangle, endangle; @@ -3413,7 +3413,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer Points.push_back(center); } else if ((*it)->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) { - const Part::GeomArcOfParabola *aop = dynamic_cast(*it); + const Part::GeomArcOfParabola *aop = static_cast(*it); Handle(Geom_TrimmedCurve) curve = Handle(Geom_TrimmedCurve)::DownCast(aop->handle()); double startangle, endangle;