From 0bef4e82f2f8fd9826be27185369818e7162d4a8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 24 Jul 2022 22:29:06 +0200 Subject: [PATCH] Fix several clazy issue: * Missing reference in range-for with non trivial type [-Wclazy-range-loop-reference] --- src/App/DocumentObjectPyImp.cpp | 2 +- src/App/ExtensionContainer.h | 2 +- src/Base/Parameter.cpp | 2 +- src/Gui/CommandLink.cpp | 2 +- src/Gui/CommandPyImp.cpp | 2 +- src/Gui/DlgAddProperty.cpp | 2 +- src/Gui/DlgPropertyLink.cpp | 8 ++++---- src/Gui/DlgPropertyLink.h | 2 +- src/Gui/SplitView3DInventor.cpp | 2 +- src/Gui/Tree.cpp | 6 +++--- src/Gui/View3DPy.cpp | 2 +- src/Gui/ViewProviderLink.cpp | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index 92cba813f3..b61edfd00a 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -696,7 +696,7 @@ PyObject* DocumentObjectPy::getPathsByOutList(PyObject *args) (o)->getDocumentObjectPtr(); auto array = getDocumentObjectPtr()->getPathsByOutList(target); Py::List list; - for (auto it : array) { + for (const auto& it : array) { Py::List path; for (auto jt : it) { path.append(Py::asObject(jt->getPyObject())); diff --git a/src/App/ExtensionContainer.h b/src/App/ExtensionContainer.h index 30d28adecf..43b45eb25f 100644 --- a/src/App/ExtensionContainer.h +++ b/src/App/ExtensionContainer.h @@ -137,7 +137,7 @@ public: template std::vector getExtensionsDerivedFromType() const { std::vector typevec; - for(auto entry : _extensions) { + for(const auto& entry : _extensions) { if(entry.first.isDerivedFrom(ExtensionT::getExtensionClassTypeId())) typevec.push_back(static_cast(entry.second)); } diff --git a/src/Base/Parameter.cpp b/src/Base/Parameter.cpp index fe020d0385..49eb5b9847 100644 --- a/src/Base/Parameter.cpp +++ b/src/Base/Parameter.cpp @@ -923,7 +923,7 @@ void ParameterGrp::Clear(void) } // remove group handles - for (auto it : removeGrp) { + for (const auto& it : removeGrp) { auto pos = _GroupMap.find(it); vecNodes.push_back(pos->second->_pGroupNode); _GroupMap.erase(pos->first); diff --git a/src/Gui/CommandLink.cpp b/src/Gui/CommandLink.cpp index fc04f90864..56f597e0b3 100644 --- a/src/Gui/CommandLink.cpp +++ b/src/Gui/CommandLink.cpp @@ -356,7 +356,7 @@ static void linkConvert(bool unlink) { // PropertyLinkBase::CopyOnLinkReplace(). std::map, Info> infos; - for(auto sel : TreeWidget::getSelection()) { + for(const auto& sel : TreeWidget::getSelection()) { auto obj = sel.vp->getObject(); auto parent = sel.parentVp; if(!parent) { diff --git a/src/Gui/CommandPyImp.cpp b/src/Gui/CommandPyImp.cpp index 0070a4a807..99064c72b0 100644 --- a/src/Gui/CommandPyImp.cpp +++ b/src/Gui/CommandPyImp.cpp @@ -118,7 +118,7 @@ PyObject* CommandPy::listByShortcut(PyObject *args) PyObject* pyList = PyList_New(matches.size()); int i=0; - for (std::string match : matches) { + for (const std::string& match : matches) { PyObject* str = PyUnicode_FromString(match.c_str()); PyList_SetItem(pyList, i++, str); } diff --git a/src/Gui/DlgAddProperty.cpp b/src/Gui/DlgAddProperty.cpp index f97f38b87f..2fe4d34065 100644 --- a/src/Gui/DlgAddProperty.cpp +++ b/src/Gui/DlgAddProperty.cpp @@ -56,7 +56,7 @@ DlgAddProperty::DlgAddProperty(QWidget* parent, std::vector types; Base::Type::getAllDerivedFrom(Base::Type::fromName("App::Property"),types); - for(auto type : types) { + for(const auto& type : types) { ui->comboType->addItem(QString::fromLatin1(type.getName())); if(type == defType) ui->comboType->setCurrentIndex(ui->comboType->count()-1); diff --git a/src/Gui/DlgPropertyLink.cpp b/src/Gui/DlgPropertyLink.cpp index 63bd12a3f4..5ee99da6b2 100644 --- a/src/Gui/DlgPropertyLink.cpp +++ b/src/Gui/DlgPropertyLink.cpp @@ -353,7 +353,7 @@ void DlgPropertyLink::init(const App::DocumentObjectT &prop, bool tryFilter) { // For link list type property, try to auto filter type if(tryFilter && isLinkList) { Base::Type objType; - for(auto link : oldLinks) { + for(const auto& link : oldLinks) { auto obj = link.getSubObject(); if(!obj) continue; @@ -745,7 +745,7 @@ QList DlgPropertyLink::originalLinks() const return oldLinks; } -QString DlgPropertyLink::linksToPython(QList links) { +QString DlgPropertyLink::linksToPython(const QList& links) { if(links.isEmpty()) return QLatin1String("None"); @@ -756,7 +756,7 @@ QString DlgPropertyLink::linksToPython(QList links) { if(isLinkSub(links)) { ss << '(' << links.front().getObjectPython() << ", ["; - for(auto link : links) { + for(const auto& link : links) { const auto &sub = link.getSubName(); if(sub.size()) ss << "u'" << Base::Tools::escapedUnicodeFromUtf8(sub.c_str()) << "',"; @@ -764,7 +764,7 @@ QString DlgPropertyLink::linksToPython(QList links) { ss << "])"; } else { ss << '['; - for(auto link : links) + for(const auto& link : links) ss << link.getSubObjectPython(false) << ','; ss << ']'; } diff --git a/src/Gui/DlgPropertyLink.h b/src/Gui/DlgPropertyLink.h index 42b7362901..d13b19a649 100644 --- a/src/Gui/DlgPropertyLink.h +++ b/src/Gui/DlgPropertyLink.h @@ -49,7 +49,7 @@ public: void init(const App::DocumentObjectT &prop, bool tryFilter=true); - static QString linksToPython(QList links); + static QString linksToPython(const QList& links); static QList getLinksFromProperty(const App::PropertyLinkBase *prop); diff --git a/src/Gui/SplitView3DInventor.cpp b/src/Gui/SplitView3DInventor.cpp index 125e2bc5e2..de82e37a94 100644 --- a/src/Gui/SplitView3DInventor.cpp +++ b/src/Gui/SplitView3DInventor.cpp @@ -502,7 +502,7 @@ Py::Object AbstractSplitViewPy::getattr(const char * attr) if (name == "__dict__" || name == "__class__") { Py::Dict dict_self(BaseType::getattr("__dict__")); Py::Dict dict_base(base.getattr("__dict__")); - for (auto it : dict_base) { + for (const auto& it : dict_base) { dict_self.setItem(it.first, it.second); } return dict_self; diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 3e894122fd..1b97a19291 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -3387,7 +3387,7 @@ void TreeWidget::_slotDeleteObject(const Gui::ViewProviderDocumentObject& view, bool needUpdate = false; - for (auto data : itEntry->second) { + for (const auto& data : itEntry->second) { DocumentItem* docItem = data->docItem; if (docItem == deletingDoc) continue; @@ -3701,7 +3701,7 @@ void TreeWidget::slotChangeObject( const char* label = obj->Label.getValue(); auto firstData = *itEntry->second.begin(); if (firstData->label != label) { - for (auto data : itEntry->second) { + for (const auto& data : itEntry->second) { data->label = label; auto displayName = QString::fromUtf8(label); for (auto item : data->items) @@ -3715,7 +3715,7 @@ void TreeWidget::slotChangeObject( const char* label = obj->Label2.getValue(); auto firstData = *itEntry->second.begin(); if (firstData->label2 != label) { - for (auto data : itEntry->second) { + for (const auto& data : itEntry->second) { data->label2 = label; auto displayName = QString::fromUtf8(label); for (auto item : data->items) diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 5b3c862df4..6593d741ef 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -282,7 +282,7 @@ Py::Object View3DInventorPy::getattribute(const char * attr) if (name == "__dict__" || name == "__class__") { Py::Dict dict_self(BaseType::getattr("__dict__")); Py::Dict dict_base(base.getattr("__dict__")); - for (auto it : dict_base) { + for (const auto& it : dict_base) { dict_self.setItem(it.first, it.second); } return dict_self; diff --git a/src/Gui/ViewProviderLink.cpp b/src/Gui/ViewProviderLink.cpp index 205f3967d9..9950a04c96 100644 --- a/src/Gui/ViewProviderLink.cpp +++ b/src/Gui/ViewProviderLink.cpp @@ -646,7 +646,7 @@ public: dot = next; } - for(auto v : nodeMap) { + for(const auto& v : nodeMap) { if(v.second->getDetail(true,type,subname,det,path)) return true; }