From 985f0a913226fedc4c29711968eb2a3f2f8d8d00 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 25 Jul 2022 10:01:49 +0200 Subject: [PATCH] Surface: Fix several clazy issues: * Missing reference in range-for with non trivial type [-Wclazy-range-loop-reference] * Use multi-arg instead [-Wclazy-qstring-arg] --- src/Mod/Surface/App/FeatureFilling.cpp | 6 ++-- .../Surface/App/FeatureGeomFillSurface.cpp | 2 +- src/Mod/Surface/App/FeatureSewing.cpp | 2 +- src/Mod/Surface/Gui/TaskFilling.cpp | 28 +++++++++---------- src/Mod/Surface/Gui/TaskFillingEdge.cpp | 12 ++++---- src/Mod/Surface/Gui/TaskFillingVertex.cpp | 12 ++++---- src/Mod/Surface/Gui/TaskGeomFillSurface.cpp | 16 +++++------ src/Mod/Surface/Gui/TaskSections.cpp | 20 ++++++------- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/Mod/Surface/App/FeatureFilling.cpp b/src/Mod/Surface/App/FeatureFilling.cpp index 946bcaea43..f0ef4ae9c0 100644 --- a/src/Mod/Surface/App/FeatureFilling.cpp +++ b/src/Mod/Surface/App/FeatureFilling.cpp @@ -245,12 +245,12 @@ void Filling::addConstraints(BRepFill_Filling& builder, const App::PropertyLinkSubList& pointsList) { auto points = pointsList.getSubListValues(); - for (auto it : points) { + for (const auto& it : points) { App::DocumentObject* obj = it.first; std::vector sub = it.second; if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); - for (auto jt : sub) { + for (const auto& jt : sub) { TopoDS_Shape subShape = shape.getSubShape(jt.c_str()); if (!subShape.IsNull() && subShape.ShapeType() == TopAbs_VERTEX) { gp_Pnt pnt = BRep_Tool::Pnt(TopoDS::Vertex(subShape)); @@ -288,7 +288,7 @@ App::DocumentObjectExecReturn *Filling::execute(void) if (initFace && initFace->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { const Part::TopoShape& shape = static_cast(initFace)->Shape.getShape(); std::vector subNames = InitialFace.getSubValues(); - for (auto it : subNames) { + for (const auto& it : subNames) { TopoDS_Shape subShape = shape.getSubShape(it.c_str()); if (!subShape.IsNull() && subShape.ShapeType() == TopAbs_FACE) { builder.LoadInitSurface(TopoDS::Face(subShape)); diff --git a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp index d18dcd868b..f4ca4bd91b 100644 --- a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp +++ b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp @@ -218,7 +218,7 @@ bool GeomFillSurface::getWire(TopoDS_Wire& aWire) App::PropertyLinkSubList::SubSet set = boundary[i]; if (set.first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { - for (auto jt: set.second) { + for (const auto& jt: set.second) { const Part::TopoShape &ts = static_cast(set.first)->Shape.getShape(); validator.checkAndAdd(ts, jt.c_str(), &aWD); } diff --git a/src/Mod/Surface/App/FeatureSewing.cpp b/src/Mod/Surface/App/FeatureSewing.cpp index c9971dd147..253acd2935 100644 --- a/src/Mod/Surface/App/FeatureSewing.cpp +++ b/src/Mod/Surface/App/FeatureSewing.cpp @@ -86,7 +86,7 @@ App::DocumentObjectExecReturn *Sewing::execute(void) Part::TopoShape ts = static_cast(it->first)->Shape.getShape(); //we want only the subshape which is linked - for (auto jt: it->second) { + for (const auto& jt: it->second) { TopoDS_Shape sub = ts.getSubShape(jt.c_str()); builder.Add(sub); } diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index e0d0c86ff7..6c42283de5 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -102,7 +102,7 @@ QIcon ViewProviderFilling::getIcon(void) const void ViewProviderFilling::highlightReferences(ShapeType type, const References& refs, bool on) { - for (auto it : refs) { + for (const auto& it : refs) { Part::Feature* base = dynamic_cast(it.first); if (base) { PartGui::ViewProviderPartExt* svp = dynamic_cast( @@ -116,7 +116,7 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References& TopExp::MapShapes(base->Shape.getValue(), TopAbs_VERTEX, vMap); colors.resize(vMap.Extent(), svp->PointColor.getValue()); - for (auto jt : it.second) { + for (const auto& jt : it.second) { // check again that the index is in range because it's possible that the // sub-names are invalid std::size_t idx = static_cast(std::stoi(jt.substr(6)) - 1); @@ -137,7 +137,7 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References& TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap); colors.resize(eMap.Extent(), svp->LineColor.getValue()); - for (auto jt : it.second) { + for (const auto& jt : it.second) { std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); // check again that the index is in range because it's possible that the // sub-names are invalid @@ -158,7 +158,7 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References& TopExp::MapShapes(base->Shape.getValue(), TopAbs_FACE, fMap); colors.resize(fMap.Extent(), svp->ShapeColor.getValue()); - for (auto jt : it.second) { + for (const auto& jt : it.second) { std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); // check again that the index is in range because it's possible that the // sub-names are invalid @@ -234,9 +234,9 @@ private: return false; auto links = editedObject->BoundaryEdges.getSubListValues(); - for (auto it : links) { + for (const auto& it : links) { if (it.first == pObj) { - for (auto jt : it.second) { + for (const auto& jt : it.second) { if (jt == sSubName) return !appendEdges; } @@ -295,8 +295,8 @@ void FillingPanel::setEditedObject(Surface::Filling* fea) const std::vector& subList = editedObject->InitialFace.getSubValues(); if (initFace && subList.size() == 1) { QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(initFace->Label.getValue())) - .arg(QString::fromStdString(subList.front())); + .arg(QString::fromUtf8(initFace->Label.getValue()), + QString::fromStdString(subList.front())); ui->lineInitFaceName->setText(text); } @@ -329,8 +329,8 @@ void FillingPanel::setEditedObject(Surface::Filling* fea) ui->listBoundary->addItem(item); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(obj->Label.getValue())) - .arg(QString::fromStdString(edge)); + .arg(QString::fromUtf8(obj->Label.getValue()), + QString::fromStdString(edge)); item->setText(text); // The user data field of a list widget item @@ -581,8 +581,8 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) if (selectionMode == InitFace) { Gui::SelectionObject sel(msg); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(sel.getObject()->Label.getValue())) - .arg(QString::fromLatin1(msg.pSubName)); + .arg(QString::fromUtf8(sel.getObject()->Label.getValue()), + QString::fromLatin1(msg.pSubName)); ui->lineInitFaceName->setText(text); std::vector subList; @@ -603,8 +603,8 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) Gui::SelectionObject sel(msg); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(sel.getObject()->Label.getValue())) - .arg(QString::fromLatin1(msg.pSubName)); + .arg(QString::fromUtf8(sel.getObject()->Label.getValue()), + QString::fromLatin1(msg.pSubName)); item->setText(text); QList data; diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.cpp b/src/Mod/Surface/Gui/TaskFillingEdge.cpp index 0f5db36719..d7d82bb87d 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.cpp +++ b/src/Mod/Surface/Gui/TaskFillingEdge.cpp @@ -97,9 +97,9 @@ private: return false; auto links = editedObject->UnboundEdges.getSubListValues(); - for (auto it : links) { + for (const auto& it : links) { if (it.first == pObj) { - for (auto jt : it.second) { + for (const auto& jt : it.second) { if (jt == sSubName) return !appendEdges; } @@ -179,8 +179,8 @@ void FillingEdgePanel::setEditedObject(Surface::Filling* fea) ui->listUnbound->addItem(item); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(obj->Label.getValue())) - .arg(QString::fromStdString(edge)); + .arg(QString::fromUtf8(obj->Label.getValue()), + QString::fromStdString(edge)); item->setText(text); // The user data field of a list widget item @@ -381,8 +381,8 @@ void FillingEdgePanel::onSelectionChanged(const Gui::SelectionChanges& msg) Gui::SelectionObject sel(msg); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(sel.getObject()->Label.getValue())) - .arg(QString::fromLatin1(msg.pSubName)); + .arg(QString::fromUtf8(sel.getObject()->Label.getValue()), + QString::fromLatin1(msg.pSubName)); item->setText(text); QList data; diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp index 59ea024c37..ea8ec684f8 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.cpp +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -96,9 +96,9 @@ private: return false; auto links = editedObject->Points.getSubListValues(); - for (auto it : links) { + for (const auto& it : links) { if (it.first == pObj) { - for (auto jt : it.second) { + for (const auto& jt : it.second) { if (jt == sSubName) return !appendVertex; } @@ -160,8 +160,8 @@ void FillingVertexPanel::setEditedObject(Surface::Filling* obj) ui->listFreeVertex->addItem(item); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8((*it)->Label.getValue())) - .arg(QString::fromStdString(*jt)); + .arg(QString::fromUtf8((*it)->Label.getValue()), + QString::fromStdString(*jt)); item->setText(text); QList data; @@ -259,8 +259,8 @@ void FillingVertexPanel::onSelectionChanged(const Gui::SelectionChanges& msg) Gui::SelectionObject sel(msg); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(sel.getObject()->Label.getValue())) - .arg(QString::fromLatin1(msg.pSubName)); + .arg(QString::fromUtf8(sel.getObject()->Label.getValue()), + QString::fromLatin1(msg.pSubName)); item->setText(text); QList data; diff --git a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp index d14029663d..d4d4b85d65 100644 --- a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp +++ b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp @@ -106,7 +106,7 @@ void ViewProviderGeomFillSurface::highlightReferences(bool on) { Surface::GeomFillSurface* surface = static_cast(getObject()); auto bounds = surface->BoundaryList.getSubListValues(); - for (auto it : bounds) { + for (const auto& it : bounds) { Part::Feature* base = dynamic_cast(it.first); if (base) { PartGui::ViewProviderPartExt* svp = dynamic_cast( @@ -118,7 +118,7 @@ void ViewProviderGeomFillSurface::highlightReferences(bool on) TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap); colors.resize(eMap.Extent(), svp->LineColor.getValue()); - for (auto jt : it.second) { + for (const auto& jt : it.second) { std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); assert (idx < colors.size()); colors[idx] = App::Color(1.0,0.0,1.0); // magenta @@ -171,9 +171,9 @@ bool GeomFillSurface::EdgeSelection::allow(App::Document* , App::DocumentObject* return false; auto links = editedObject->BoundaryList.getSubListValues(); - for (auto it : links) { + for (const auto& it : links) { if (it.first == pObj) { - for (auto jt : it.second) { + for (const auto& jt : it.second) { if (jt == sSubName) return !appendEdges; } @@ -258,8 +258,8 @@ void GeomFillSurface::setEditedObject(Surface::GeomFillSurface* obj) ui->listWidget->addItem(item); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8((*it)->Label.getValue())) - .arg(QString::fromStdString(*jt)); + .arg(QString::fromUtf8((*it)->Label.getValue()), + QString::fromStdString(*jt)); item->setText(text); QList data; @@ -424,8 +424,8 @@ void GeomFillSurface::onSelectionChanged(const Gui::SelectionChanges& msg) Gui::SelectionObject sel(msg); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(sel.getObject()->Label.getValue())) - .arg(QString::fromLatin1(msg.pSubName)); + .arg(QString::fromUtf8(sel.getObject()->Label.getValue()), + QString::fromLatin1(msg.pSubName)); item->setText(text); QList data; diff --git a/src/Mod/Surface/Gui/TaskSections.cpp b/src/Mod/Surface/Gui/TaskSections.cpp index 6182253a28..d2076547ff 100644 --- a/src/Mod/Surface/Gui/TaskSections.cpp +++ b/src/Mod/Surface/Gui/TaskSections.cpp @@ -106,7 +106,7 @@ QIcon ViewProviderSections::getIcon(void) const void ViewProviderSections::highlightReferences(ShapeType type, const References& refs, bool on) { - for (auto it : refs) { + for (const auto& it : refs) { Part::Feature* base = dynamic_cast(it.first); if (base) { PartGui::ViewProviderPartExt* svp = dynamic_cast( @@ -120,7 +120,7 @@ void ViewProviderSections::highlightReferences(ShapeType type, const References& TopExp::MapShapes(base->Shape.getValue(), TopAbs_VERTEX, vMap); colors.resize(vMap.Extent(), svp->PointColor.getValue()); - for (auto jt : it.second) { + for (const auto& jt : it.second) { // check again that the index is in range because it's possible that the // sub-names are invalid std::size_t idx = static_cast(std::stoi(jt.substr(6)) - 1); @@ -141,7 +141,7 @@ void ViewProviderSections::highlightReferences(ShapeType type, const References& TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap); colors.resize(eMap.Extent(), svp->LineColor.getValue()); - for (auto jt : it.second) { + for (const auto& jt : it.second) { std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); // check again that the index is in range because it's possible that the // sub-names are invalid @@ -162,7 +162,7 @@ void ViewProviderSections::highlightReferences(ShapeType type, const References& TopExp::MapShapes(base->Shape.getValue(), TopAbs_FACE, fMap); colors.resize(fMap.Extent(), svp->ShapeColor.getValue()); - for (auto jt : it.second) { + for (const auto& jt : it.second) { std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); // check again that the index is in range because it's possible that the // sub-names are invalid @@ -229,9 +229,9 @@ private: return false; auto links = editedObject->NSections.getSubListValues(); - for (auto it : links) { + for (const auto& it : links) { if (it.first == pObj) { - for (auto jt : it.second) { + for (const auto& jt : it.second) { if (jt == sSubName) return !appendEdges; } @@ -295,8 +295,8 @@ void SectionsPanel::setEditedObject(Surface::Sections* fea) ui->listSections->addItem(item); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(obj->Label.getValue())) - .arg(QString::fromStdString(edge)); + .arg(QString::fromUtf8(obj->Label.getValue()), + QString::fromStdString(edge)); item->setText(text); // The user data field of a list widget item @@ -428,8 +428,8 @@ void SectionsPanel::onSelectionChanged(const Gui::SelectionChanges& msg) Gui::SelectionObject sel(msg); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8(sel.getObject()->Label.getValue())) - .arg(QString::fromLatin1(msg.pSubName)); + .arg(QString::fromUtf8(sel.getObject()->Label.getValue()), + QString::fromLatin1(msg.pSubName)); item->setText(text); QList data;