From 0cfc0cd424a8b77046d413ab14ba620dde7b8406 Mon Sep 17 00:00:00 2001 From: Alexander Golubev Date: Tue, 10 Nov 2015 16:58:27 +0300 Subject: [PATCH] Fix warnings introduced in new PartDesign Mostly unused wariables and compare of signed & unsigned --- src/Mod/PartDesign/App/Body.cpp | 2 - src/Mod/PartDesign/App/FeatureLoft.cpp | 4 +- src/Mod/PartDesign/App/FeaturePad.cpp | 2 - src/Mod/PartDesign/App/FeaturePipe.cpp | 4 +- src/Mod/PartDesign/App/ShapeBinder.cpp | 2 +- src/Mod/PartDesign/Gui/Command.cpp | 10 +---- .../PartDesign/Gui/TaskBooleanParameters.cpp | 2 +- .../PartDesign/Gui/TaskDatumParameters.cpp | 44 ++++++++----------- src/Mod/PartDesign/Gui/TaskDatumParameters.h | 7 +-- .../PartDesign/Gui/TaskDressUpParameters.cpp | 5 +-- src/Mod/PartDesign/Gui/TaskFeaturePick.cpp | 1 - .../Gui/TaskPrimitiveParameters.cpp | 4 +- .../Gui/TaskRevolutionParameters.cpp | 6 +-- .../Gui/TaskSketchBasedParameters.cpp | 1 - .../Gui/TaskTransformedParameters.cpp | 6 +-- src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp | 1 - src/Mod/PartDesign/Gui/ViewProviderBody.cpp | 2 - .../PartDesign/Gui/ViewProviderDatumLine.cpp | 2 - .../PartDesign/Gui/ViewProviderDatumPlane.cpp | 2 - .../PartDesign/Gui/ViewProviderDressUp.cpp | 11 +++-- src/Mod/PartDesign/Gui/ViewProviderPipe.cpp | 5 ++- .../Gui/ViewProviderShapeBinder.cpp | 15 ++++--- src/Mod/Sketcher/App/SketchObject.cpp | 2 +- src/Mod/Sketcher/Gui/Command.cpp | 6 +-- src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 1 - 25 files changed, 60 insertions(+), 87 deletions(-) diff --git a/src/Mod/PartDesign/App/Body.cpp b/src/Mod/PartDesign/App/Body.cpp index 0179eeba2..4e772d32e 100644 --- a/src/Mod/PartDesign/App/Body.cpp +++ b/src/Mod/PartDesign/App/Body.cpp @@ -391,8 +391,6 @@ App::DocumentObjectExecReturn *Body::execute(void) return new App::DocumentObjectExecReturn ( "Linked object is not a PartDesign feature" ); } - App::DocumentObject* link = Tip.getValue(); - // get the shape of the tip tipShape = static_cast(tip)->Shape.getShape(); diff --git a/src/Mod/PartDesign/App/FeatureLoft.cpp b/src/Mod/PartDesign/App/FeatureLoft.cpp index d4506e418..337df6077 100644 --- a/src/Mod/PartDesign/App/FeatureLoft.cpp +++ b/src/Mod/PartDesign/App/FeatureLoft.cpp @@ -74,10 +74,8 @@ short Loft::mustExecute() const App::DocumentObjectExecReturn *Loft::execute(void) { - Part::Part2DObject* sketch = 0; std::vector wires; try { - sketch = getVerifiedSketch(); wires = getSketchWires(); } catch (const Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); @@ -116,7 +114,7 @@ App::DocumentObjectExecReturn *Loft::execute(void) return new App::DocumentObjectExecReturn("Loft: All sections need to be part features"); TopExp_Explorer ex; - int i=0; + size_t i=0; for (ex.Init(static_cast(obj)->Shape.getValue(), TopAbs_WIRE); ex.More(); ex.Next(), ++i) { if(i>=wiresections.size()) return new App::DocumentObjectExecReturn("Loft: Sections need to have the same amount of inner wires as the base section"); diff --git a/src/Mod/PartDesign/App/FeaturePad.cpp b/src/Mod/PartDesign/App/FeaturePad.cpp index a50da0a64..a10a3b036 100644 --- a/src/Mod/PartDesign/App/FeaturePad.cpp +++ b/src/Mod/PartDesign/App/FeaturePad.cpp @@ -212,8 +212,6 @@ App::DocumentObjectExecReturn *Pad::execute(void) // set the additive shape property for later usage in e.g. pattern prism = refineShapeIfActive(prism); - const char* name = AddSubShape.getName(); - const char* name1 = this->getPropertyName(&AddSubShape); this->AddSubShape.setValue(prism); if (!base.IsNull()) { diff --git a/src/Mod/PartDesign/App/FeaturePipe.cpp b/src/Mod/PartDesign/App/FeaturePipe.cpp index 55d860902..86247e973 100644 --- a/src/Mod/PartDesign/App/FeaturePipe.cpp +++ b/src/Mod/PartDesign/App/FeaturePipe.cpp @@ -112,10 +112,8 @@ short Pipe::mustExecute() const App::DocumentObjectExecReturn *Pipe::execute(void) { - Part::Part2DObject* sketch = 0; std::vector wires; try { - sketch = getVerifiedSketch(); wires = getSketchWires(); } catch (const Base::Exception& e) { return new App::DocumentObjectExecReturn(e.what()); @@ -182,7 +180,7 @@ App::DocumentObjectExecReturn *Pipe::execute(void) return new App::DocumentObjectExecReturn("All sections need to be part features"); TopExp_Explorer ex; - int i=0; + size_t i=0; for (ex.Init(static_cast(obj)->Shape.getValue(), TopAbs_WIRE); ex.More(); ex.Next()) { wiresections[i].push_back(TopoDS::Wire(ex.Current())); if(i>=wiresections.size()) diff --git a/src/Mod/PartDesign/App/ShapeBinder.cpp b/src/Mod/PartDesign/App/ShapeBinder.cpp index 61ee6f44f..63c9d9654 100644 --- a/src/Mod/PartDesign/App/ShapeBinder.cpp +++ b/src/Mod/PartDesign/App/ShapeBinder.cpp @@ -83,7 +83,7 @@ void ShapeBinder::getFilterdReferences(App::PropertyLinkSubList* prop, Part::Fea } //we only allow one part feature, so get the first one we find - int index = 0; + size_t index = 0; while(!objs[index]->isDerivedFrom(Part::Feature::getClassTypeId()) && index < objs.size()) index++; diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index 87190cd93..aadf35436 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -101,10 +101,7 @@ void UnifiedDatumCommand(Gui::Command &cmd, Base::Type type, std::string name) cmd.doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s')",support.getValue()->getNameInDocument()); } else if (pcActiveBody) { - auto pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false); - // TODO Check how this will work outside of a body (2015-10-20, Fat-Zer) - // TODO rewrite this to be shared with CmdPartDesignNewSketch::activated() (2015-10-20, Fat-Zer) std::string FeatName = cmd.getUniqueObjectName(name.c_str()); std::string tmp = std::string("Create ")+name; @@ -281,10 +278,8 @@ void CmdPartDesignShapeBinder::activated(int iMsg) //test if current selection fits a mode. if (support.getSize() > 0) { - AttachableObject* pcDatum = static_cast( - getDocument()->getObject(FeatName.c_str())); doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = %s", - FeatName.c_str(),support.getPyReprString().c_str()); + FeatName.c_str(), support.getPyReprString().c_str()); } doCommand(Gui::Command::Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)", pcActiveBody->getNameInDocument(), FeatName.c_str()); @@ -532,7 +527,6 @@ void CmdPartDesignNewSketch::activated(int iMsg) }; // If there is more than one possibility, show dialog and let user pick plane - bool reversed = false; if (validPlanes > 1) { Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); @@ -1813,11 +1807,9 @@ void CmdPartDesignBoolean::activated(int iMsg) if (!pcActiveBody) return; Gui::SelectionFilter BodyFilter("SELECT PartDesign::Body COUNT 1.."); - PartDesign::Body* body = nullptr; std::string bodyString(""); if (BodyFilter.match()) { - body = static_cast(BodyFilter.Result[0][0].getObject()); std::vector bodies; std::vector >::iterator i = BodyFilter.Result.begin(); for (; i != BodyFilter.Result.end(); i++) { diff --git a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp index e3e865f64..f430cb7e5 100644 --- a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp @@ -236,7 +236,7 @@ void TaskBooleanParameters::onBodyDeleted(void) PartDesign::Boolean* pcBoolean = static_cast(BooleanView->getObject()); std::vector bodies = pcBoolean->Bodies.getValues(); int index = ui->listWidgetBodies->currentRow(); - if (index > bodies.size()) + if (index < 0 && (size_t) index > bodies.size()) return; App::DocumentObject* body = bodies[index]; bodies.erase(bodies.begin() + ui->listWidgetBodies->currentRow()); diff --git a/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp b/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp index 0c4843b77..566b6f686 100644 --- a/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDatumParameters.cpp @@ -96,7 +96,7 @@ void TaskDatumParameters::makeRefStrings(std::vector& refstrings, std:: std::vector refs = pcDatum->Support.getValues(); refnames = pcDatum->Support.getSubValues(); - for (int r = 0; r < 4; r++) { + for (size_t r = 0; r < 4; r++) { if ((r < refs.size()) && (refs[r] != NULL)) { refstrings.push_back(makeRefString(refs[r], refnames[r])); } else { @@ -312,7 +312,8 @@ void TaskDatumParameters::updateUI(std::string message, bool error) // Get hints for further required references eSuggestResult msg; std::set hint; - eMapMode suggMode = pcDatum->attacher().listMapModes(msg,0,&hint); + + pcDatum->attacher().listMapModes(msg,0,&hint); if (msg != srOK) { if(hint.size() > 0) @@ -374,18 +375,15 @@ void TaskDatumParameters::updateUI(std::string message, bool error) } } -QLineEdit* TaskDatumParameters::getLine(const int idx) +QLineEdit* TaskDatumParameters::getLine(unsigned idx) { - if (idx == 0) - return ui->lineRef1; - else if (idx == 1) - return ui->lineRef2; - else if (idx == 2) - return ui->lineRef3; - else if (idx == 3) - return ui->lineRef4; - else - return NULL; + switch(idx) { + case 0: return ui->lineRef1; + case 1: return ui->lineRef2; + case 2: return ui->lineRef3; + case 3: return ui->lineRef4; + default: return NULL; + } } void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg) @@ -408,11 +406,11 @@ void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg) subname = ""; // eliminate duplicate selections - for (int r = 0; r < refs.size(); r++) + for (size_t r = 0; r < refs.size(); r++) if ((refs[r] == selObj) && (refnames[r] == subname)) return; - if (autoNext && iActiveRef > 0 && iActiveRef == refnames.size()){ + if (autoNext && iActiveRef > 0 && iActiveRef == (ssize_t) refnames.size()){ if (refs[iActiveRef-1] == selObj && refnames[iActiveRef-1].length() != 0 && subname.length() == 0){ //A whole object was selected by clicking it twice. Fill it @@ -422,7 +420,7 @@ void TaskDatumParameters::onSelectionChanged(const Gui::SelectionChanges& msg) iActiveRef--; } } - if (iActiveRef < refs.size()) { + if (iActiveRef < (ssize_t) refs.size()) { refs[iActiveRef] = selObj; refnames[iActiveRef] = subname; } else { @@ -521,7 +519,7 @@ void TaskDatumParameters::onCheckFlip(bool on) pcDatum->getDocument()->recomputeFeature(pcDatum); } -void TaskDatumParameters::onButtonRef(const bool checked, const int idx) +void TaskDatumParameters::onButtonRef(const bool checked, unsigned idx) { autoNext = false; if (checked) { @@ -555,7 +553,7 @@ void TaskDatumParameters::onModeSelect() pcDatum->MapMode.setValue(getActiveMapMode()); } -void TaskDatumParameters::onRefName(const QString& text, const int idx) +void TaskDatumParameters::onRefName(const QString& text, unsigned idx) { QLineEdit* line = getLine(idx); if (line == NULL) return; @@ -568,7 +566,7 @@ void TaskDatumParameters::onRefName(const QString& text, const int idx) std::vector refnames = pcDatum->Support.getSubValues(); std::vector newrefs; std::vector newrefnames; - for (int r = 0; r < refs.size(); r++) { + for (size_t r = 0; r < refs.size(); r++) { if (r != idx) { newrefs.push_back(refs[r]); newrefnames.push_back(refnames[r]); @@ -601,7 +599,6 @@ void TaskDatumParameters::onRefName(const QString& text, const int idx) if (obj == NULL) return; std::string subElement; - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) { // everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree) @@ -690,7 +687,7 @@ void TaskDatumParameters::updateListOfModes(eMapMode curMode) ui->listOfModes->clear(); QListWidgetItem* iSelect = 0; if (modesInList.size()>0) { - for( int i = 0 ; i < modesInList.size() ; i++){ + for (size_t i = 0 ; i < modesInList.size() ; ++i){ eMapMode mmode = modesInList[i]; ui->listOfModes->addItem(QString::fromLatin1(AttachEngine::eMapModeStrings[mmode])); if (mmode == curMode) @@ -874,7 +871,6 @@ bool TaskDlgDatumParameters::accept() std::vector copies; //see if we are able to assign a mode - bool bIgnoreError = false; if (parameter->getActiveMapMode() == mmDeactivated) { QMessageBox msg; msg.setWindowTitle(tr("Incompatible reference set")); @@ -882,7 +878,7 @@ bool TaskDlgDatumParameters::accept() " of references. If you choose to continue, the feature will remain where" " it is now, and will not be moved as the references change." " Continue?")); - auto btYes = msg.addButton(QMessageBox::Yes); + msg.addButton(QMessageBox::Yes); auto btNo = msg.addButton(QMessageBox::No); msg.setDefaultButton(btNo); msg.setIcon(QMessageBox::Warning); @@ -971,8 +967,6 @@ bool TaskDlgDatumParameters::reject() Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); - return true; } diff --git a/src/Mod/PartDesign/Gui/TaskDatumParameters.h b/src/Mod/PartDesign/Gui/TaskDatumParameters.h index 452302323..ce6a9d771 100644 --- a/src/Mod/PartDesign/Gui/TaskDatumParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDatumParameters.h @@ -93,9 +93,9 @@ private: void updateUI(std::string message = std::string(), bool isWarning = false); void makeRefStrings(std::vector& refstrings, std::vector& refnames); - QLineEdit* getLine(const int idx); - void onButtonRef(const bool checked, const int idx); - void onRefName(const QString& text, const int idx); + QLineEdit* getLine(unsigned idx); + void onButtonRef(const bool checked, unsigned idx); + void onRefName(const QString& text, unsigned idx); /** * @brief updateListOfModes Fills the mode list with modes that apply to @@ -111,6 +111,7 @@ private: Ui_TaskDatumParameters* ui; ViewProviderDatum *DatumView; + // TODO fix documentation here (2015-11-10, Fat-Zer) int iActiveRef; //what reference is being picked in 3d view now? -1 means no one, 0-2 means a reference is being picked. bool autoNext;//if we should automatically switch to next reference (true after dialog launch, false afterwards) std::vector modesInList; //this list is synchronous to what is populated into listOfModes widget. diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index a8f28351b..eb0d18b45 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -48,12 +48,11 @@ using namespace Gui; /* TRANSLATOR PartDesignGui::TaskDressUpParameters */ TaskDressUpParameters::TaskDressUpParameters(ViewProviderDressUp *DressUpView, bool selectEdges, bool selectFaces, QWidget *parent) - : allowFaces(selectFaces), allowEdges(selectEdges), - TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + DressUpView->featureName()).c_str()), + : TaskBox(Gui::BitmapFactory().pixmap((std::string("PartDesign_") + DressUpView->featureName()).c_str()), QString::fromAscii((DressUpView->featureName() + " parameters").c_str()), true, parent), - DressUpView(DressUpView) + DressUpView(DressUpView), allowFaces(selectFaces), allowEdges(selectEdges) { selectionMode = none; } diff --git a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp index 06e745445..412a3189a 100644 --- a/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeaturePick.cpp @@ -119,7 +119,6 @@ TaskFeaturePick::TaskFeaturePick(std::vector& objects, // Setup the origin's temporary visability for ( const auto & originPair: originVisStatus ) { const auto &origin = originPair.first; - const auto &status = originPair.second; Gui::ViewProviderOrigin* vpo = static_cast ( Gui::Application::Instance->getViewProvider ( origin ) ); diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp index 71a2b3c77..b09b99485 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp @@ -48,7 +48,7 @@ using namespace PartDesignGui; TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) - : vp(vp), TaskBox(QPixmap(),tr("Primitive parameters"), true, parent) + : TaskBox(QPixmap(),tr("Primitive parameters"), true, parent), vp(vp) { proxy = new QWidget(this); ui.setupUi(proxy); @@ -697,4 +697,4 @@ QDialogButtonBox::StandardButtons TaskPrimitiveParameters::getStandardButtons(vo } -#include "moc_TaskPrimitiveParameters.cpp" \ No newline at end of file +#include "moc_TaskPrimitiveParameters.cpp" diff --git a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp index 5b97b2509..68b58b035 100644 --- a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp @@ -155,7 +155,7 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill) if (forceRefill){ ui->axis->clear(); - for(int i = 0 ; i < axesInList.size() ; i++ ){ + for(size_t i = 0 ; i < axesInList.size() ; i++ ){ delete axesInList[i]; } this->axesInList.clear(); @@ -198,7 +198,7 @@ void TaskRevolutionParameters::fillAxisCombo(bool forceRefill) int indexOfCurrent = -1; App::DocumentObject* ax = propReferenceAxis->getValue(); const std::vector &subList = propReferenceAxis->getSubValues(); - for(int i = 0 ; i < axesInList.size() ; i++) { + for(size_t i = 0 ; i < axesInList.size() ; i++) { if(ax == axesInList[i]->getValue() && subList == axesInList[i]->getSubValues()) indexOfCurrent = i; } @@ -373,7 +373,7 @@ TaskRevolutionParameters::~TaskRevolutionParameters() delete ui; - for(int i = 0 ; i < axesInList.size() ; i++ ){ + for(size_t i = 0 ; i < axesInList.size() ; i++ ){ delete axesInList[i]; } } diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index b107536de..7803a0ab7 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -96,7 +96,6 @@ void TaskSketchBasedParameters::onSelectReference(const bool pressed, const bool // Note: Even if there is no solid, App::Plane and Part::Datum can still be selected PartDesign::SketchBased* pcSketchBased = static_cast(vp->getObject()); - PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject(PDBODYKEY); // The solid this feature will be fused to App::DocumentObject* prevSolid = pcSketchBased->getBaseObject( /* silent =*/ true ); diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index c50eb2a04..b3f4f617d 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -422,7 +422,7 @@ int ComboLinks::addLink(App::DocumentObject *linkObj, std::string linkSubname, Q void ComboLinks::clear() { - for(int i = 0 ; i < this->linksInList.size() ; i++){ + for(size_t i = 0 ; i < this->linksInList.size() ; i++){ delete linksInList[i]; } if(this->_combo) @@ -431,7 +431,7 @@ void ComboLinks::clear() App::PropertyLinkSub &ComboLinks::getLink(int index) const { - if (index < 0 || index > linksInList.size()-1) + if (index < 0 || index > (ssize_t) linksInList.size()-1) throw Base::Exception("ComboLinks::getLink:Index out of range"); if (linksInList[index]->getValue() && doc && !(doc->isIn(linksInList[index]->getValue()))) throw Base::Exception("Linked object is not in the document; it may have been deleted"); @@ -446,7 +446,7 @@ App::PropertyLinkSub &ComboLinks::getCurrentLink() const int ComboLinks::setCurrentLink(const App::PropertyLinkSub &lnk) { - for(int i = 0 ; i < linksInList.size() ; i++) { + for(size_t i = 0 ; i < linksInList.size() ; i++) { App::PropertyLinkSub &it = *(linksInList[i]); if(lnk.getValue() == it.getValue() && lnk.getSubValues() == it.getSubValues()){ bool wasBlocked = _combo->signalsBlocked(); diff --git a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp index 7efad5eec..14e1a28d3 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp @@ -126,7 +126,6 @@ void ViewProviderAddSub::updateAddSubShapeIndicator() { bounds.Get(xMin, yMin, zMin, xMax, yMax, zMax); Standard_Real deflection = ((xMax-xMin)+(yMax-yMin)+(zMax-zMin))/300.0 * Deviation.getValue(); - Standard_Real AngDeflectionRads = AngularDeflection.getValue() / 180.0 * M_PI; // create or use the mesh on the data structure #if OCC_VERSION_HEX >= 0x060600 diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index 030f8a5e8..aab5fec62 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -186,8 +186,6 @@ std::vector ViewProviderBody::claimChildren3D(void)const PartDesign::Body* body = static_cast(getObject()); const std::vector & features = body->Model.getValues(); - App::DocumentObject *originObj = body->Origin.getValue(); - App::DocumentObject *baseFeature = body->BaseFeature.getValue(); std::vector rv; diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatumLine.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatumLine.cpp index c1bfb3da3..482e7fa73 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatumLine.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatumLine.cpp @@ -67,8 +67,6 @@ void ViewProviderDatumLine::attach ( App::DocumentObject *obj ) { void ViewProviderDatumLine::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - PartDesign::Line* pcDatum = static_cast(this->getObject()); - if (strcmp(prop->getName(),"Placement") == 0) { updateExtents (); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderDatumPlane.cpp b/src/Mod/PartDesign/Gui/ViewProviderDatumPlane.cpp index 2e3263f3f..a8673fe88 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDatumPlane.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDatumPlane.cpp @@ -89,8 +89,6 @@ void ViewProviderDatumPlane::attach ( App::DocumentObject *obj ) { void ViewProviderDatumPlane::updateData(const App::Property* prop) { // Gets called whenever a property of the attached object changes - PartDesign::Plane* pcDatum = static_cast(this->getObject()); - if (strcmp(prop->getName(),"Placement") == 0) { updateExtents (); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp b/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp index 19b8f253f..5ade7e2d6 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderDressUp.cpp @@ -104,8 +104,10 @@ void ViewProviderDressUp::highlightReferences(const bool on) colors.resize(fMap.Extent(), ShapeColor.getValue()); for (std::vector::const_iterator f = faces.begin(); f != faces.end(); ++f) { - int idx = atoi(f->substr(4).c_str()) - 1; - if (idx < colors.size()) + // Note: std::stoi may throw in case of bad or very long face name, but screw the try {} catch + int idx = std::stoi(f->substr(4)) - 1; + assert ( idx>=0 ); + if ( idx < (ssize_t) colors.size() ) colors[idx] = App::Color(1.0,0.0,1.0); // magenta } vp->DiffuseColor.setValues(colors); @@ -118,8 +120,9 @@ void ViewProviderDressUp::highlightReferences(const bool on) colors.resize(eMap.Extent(), LineColor.getValue()); for (std::vector::const_iterator e = edges.begin(); e != edges.end(); ++e) { - int idx = atoi(e->substr(4).c_str()) - 1; - if (idx < colors.size()) + int idx = std::stoi(e->substr(4)) - 1; + assert ( idx>=0 ); + if ( idx < (ssize_t) colors.size() ) colors[idx] = App::Color(1.0,0.0,1.0); // magenta } vp->LineColorArray.setValues(colors); diff --git a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp index bafb19d2f..d93063ec0 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPipe.cpp @@ -174,8 +174,9 @@ void ViewProviderPipe::highlightReferences(const bool on, bool auxillery) colors.resize(eMap.Extent(), svp->LineColor.getValue()); for (std::string e : edges) { - int idx = atoi(e.substr(4).c_str()) - 1; - if (idx < colors.size()) + int idx = std::stoi(e.substr(4)) - 1; + assert ( idx > 0 ); + if ( idx < (ssize_t) colors.size() ) colors[idx] = App::Color(1.0,0.0,1.0); // magenta } svp->LineColorArray.setValues(colors); diff --git a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp index 8aab7628b..d7a5209dc 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp @@ -140,23 +140,24 @@ void ViewProviderShapeBinder::highlightReferences(const bool on, bool auxillery) originalLineColors = svp->LineColorArray.getValues(); std::vector lcolors = originalLineColors; lcolors.resize(eMap.Extent(), svp->LineColor.getValue()); - + TopExp::MapShapes(obj->Shape.getValue(), TopAbs_FACE, eMap); originalFaceColors = svp->DiffuseColor.getValues(); std::vector fcolors = originalFaceColors; fcolors.resize(eMap.Extent(), svp->ShapeColor.getValue()); for (std::string e : subs) { + // Note: stoi may throw, but it strictly shouldn't happen if(e.substr(4) == "Edge") { - - int idx = atoi(e.substr(4).c_str()) - 1; - if (idx < lcolors.size()) + int idx = std::stoi(e.substr(4)) - 1; + assert ( idx>=0 ); + if ( idx < (ssize_t) lcolors.size() ) lcolors[idx] = App::Color(1.0,0.0,1.0); // magenta } else if(e.substr(4) == "Face") { - - int idx = atoi(e.substr(4).c_str()) - 1; - if (idx < fcolors.size()) + int idx = std::stoi(e.substr(4)) - 1; + assert ( idx>=0 ); + if ( idx < (ssize_t) fcolors.size() ) fcolors[idx] = App::Color(1.0,0.0,1.0); // magenta } } diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 2cce78edc..e0db83b8e 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -2779,7 +2779,7 @@ int SketchObject::addExternal(App::DocumentObject *Obj, const char* SubName) Base::Console().Error("Internal error: counts of objects and subelements in external geometry links do not match\n"); return -1; } - for (int i = 0 ; i < Objects.size() ; i++){ + for (size_t i = 0 ; i < Objects.size() ; ++i){ if (Objects[i] == Obj && std::string(SubName) == SubElements[i]){ Base::Console().Error("Link to %s already exists in this sketch.\n",SubName); return -1; diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index bf8d8b49a..8c9ce5d89 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -164,7 +164,7 @@ void CmdSketcherNewSketch::activated(int iMsg) QStringList items; items.push_back(QObject::tr("Don't attach")); int iSugg = 0;//index of the auto-suggested mode in the list of valid modes - for (int i = 0 ; i < validModes.size() ; ++i){ + for (size_t i = 0 ; i < validModes.size() ; ++i){ items.push_back(QString::fromLatin1(AttachEngine::eMapModeStrings[validModes[i]])); if (validModes[i] == mapmode) iSugg = items.size()-1; @@ -473,7 +473,7 @@ void CmdSketcherMapSketch::activated(int iMsg) // check circular dependency std::vector selobjs = Gui::Selection().getSelectionEx(); - for( int i = 0 ; i < selobjs.size() ; i++){ + for (size_t i = 0 ; i < selobjs.size() ; ++i){ App::DocumentObject* part = static_cast(selobjs[i].getObject()); if (!part) { assert(0); @@ -512,7 +512,7 @@ void CmdSketcherMapSketch::activated(int iMsg) items.push_back(QObject::tr("Don't attach")); int iSugg = 0;//index of the auto-suggested mode in the list of valid modes int iCurr = 0;//index of current mode in the list of valid modes - for (int i = 0 ; i < validModes.size() ; ++i){ + for (size_t i = 0 ; i < validModes.size() ; ++i){ items.push_back(QString::fromLatin1(AttachEngine::eMapModeStrings[validModes[i]])); if (validModes[i] == curMapMode) { iCurr = items.size() - 1; diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index c3dfa3c54..302a64d6f 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -236,7 +236,6 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested int tangId = Constraint::GeoUndef; - float smlTangDist = 1e15f; // Do not consider if distance is more than that. // Decrease this value when a candidate is found. double tangDeviation = 0.1 * sketchgui->getScaleFactor();