Sketcher: [skip ci] Fix several clazy issues:

* Missing reference in range-for with non trivial type [-Wclazy-range-loop-reference]
* Unused QString [-Wclazy-unused-non-trivial-variable]
* Missing emit keyword on signal call [-Wclazy-incorrect-emit]
* Don't call QList::operator[]() on temporary [-Wclazy-detaching-temporary]
* Use multi-arg instead [-Wclazy-qstring-arg]
* Maybe you meant to call ViewProvider2DObjectGrid::onChanged() instead [-Wclazy-skipped-base-method]
This commit is contained in:
wmayer
2022-07-25 12:56:09 +02:00
parent af71685a50
commit 50ef527ded
9 changed files with 21 additions and 24 deletions

View File

@@ -1708,7 +1708,7 @@ void SketchObjectPy::setMissingPointOnPointConstraints(Py::List arg)
return (checkitem(t,i,0)?Sketcher::PointPos::none:(checkitem(t,i,1)?Sketcher::PointPos::start:(checkitem(t,i,2)?Sketcher::PointPos::end:Sketcher::PointPos::mid)));
};
for (auto ti : arg) {
for (const auto& ti : arg) {
Py::Tuple t(ti);
ConstraintIds c;
c.First = (long)Py::Long(t.getItem(0));
@@ -1749,7 +1749,7 @@ void SketchObjectPy::setMissingVerticalHorizontalConstraints(Py::List arg)
return (checkitem(t,i,0)?Sketcher::PointPos::none:(checkitem(t,i,1)?Sketcher::PointPos::start:(checkitem(t,i,2)?Sketcher::PointPos::end:Sketcher::PointPos::mid)));
};
for (auto ti : arg) {
for (const auto& ti : arg) {
Py::Tuple t(ti);
ConstraintIds c;
c.First = (long)Py::Long(t.getItem(0));
@@ -1789,7 +1789,7 @@ void SketchObjectPy::setMissingLineEqualityConstraints(Py::List arg)
return (checkitem(t,i,0)?Sketcher::PointPos::none:(checkitem(t,i,1)?Sketcher::PointPos::start:(checkitem(t,i,2)?Sketcher::PointPos::end:Sketcher::PointPos::mid)));
};
for (auto ti : arg) {
for (const auto& ti : arg) {
Py::Tuple t(ti);
ConstraintIds c;
c.First = (long)Py::Long(t.getItem(0));
@@ -1829,7 +1829,7 @@ void SketchObjectPy::setMissingRadiusConstraints(Py::List arg)
return (checkitem(t,i,0)?Sketcher::PointPos::none:(checkitem(t,i,1)?Sketcher::PointPos::start:(checkitem(t,i,2)?Sketcher::PointPos::end:Sketcher::PointPos::mid)));
};
for (auto ti : arg) {
for (const auto& ti : arg) {
Py::Tuple t(ti);
ConstraintIds c;
c.First = (long)Py::Long(t.getItem(0));

View File

@@ -357,7 +357,7 @@ void SolverReportingManager::LogGroupOfConstraints(const std::string & str, std:
tempstream << str << ":" << '\n';
for(auto group : constraintgroups) {
for(const auto& group : constraintgroups) {
tempstream << "[";
for(auto c :group)

View File

@@ -4415,7 +4415,6 @@ void CmdSketcherConstrainTangent::applyConstraint(std::vector<SelIdPair> &selSeq
{
SketcherGui::ViewProviderSketch* sketchgui = static_cast<SketcherGui::ViewProviderSketch*>(getActiveGuiDocument()->getInEdit());
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
QString strError;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef, GeoId3 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::PointPos::none, PosId2 = Sketcher::PointPos::none, PosId3 = Sketcher::PointPos::none;
@@ -6403,7 +6402,6 @@ void CmdSketcherConstrainEqual::applyConstraint(std::vector<SelIdPair> &selSeq,
{
SketcherGui::ViewProviderSketch* sketchgui = static_cast<SketcherGui::ViewProviderSketch*>(getActiveGuiDocument()->getInEdit());
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
QString strError;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef;
@@ -6651,7 +6649,6 @@ void CmdSketcherConstrainSymmetric::applyConstraint(std::vector<SelIdPair> &selS
{
SketcherGui::ViewProviderSketch* sketchgui = static_cast<SketcherGui::ViewProviderSketch*>(getActiveGuiDocument()->getInEdit());
Sketcher::SketchObject* Obj = sketchgui->getSketchObject();
QString strError;
int GeoId1 = GeoEnum::GeoUndef, GeoId2 = GeoEnum::GeoUndef, GeoId3 = GeoEnum::GeoUndef;
Sketcher::PointPos PosId1 = Sketcher::PointPos::none, PosId2 = Sketcher::PointPos::none, PosId3 = Sketcher::PointPos::none;

View File

@@ -244,7 +244,7 @@ void EditDatumDialog::drivingToggled(bool state)
void EditDatumDialog::datumChanged()
{
if (ui_ins_datum->labelEdit->text() != ui_ins_datum->labelEdit->getHistory()[0]) {
if (ui_ins_datum->labelEdit->text() != qAsConst(ui_ins_datum->labelEdit)->getHistory()[0]) {
ui_ins_datum->cbDriving->setChecked(false);
}
}

View File

@@ -148,7 +148,7 @@ public:
case Sketcher::Weight:
case Sketcher::Diameter:
case Sketcher::Angle:
name = QString::fromLatin1("%1 (%2)").arg(name).arg(constraint->getPresentationValue().getUserString());
name = QString::fromLatin1("%1 (%2)").arg(name, constraint->getPresentationValue().getUserString());
break;
case Sketcher::SnellsLaw: {
double v = constraint->getPresentationValue().getValue();
@@ -537,7 +537,7 @@ void ConstraintView::updateDrivingStatus()
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
if (it) {
onUpdateDrivingStatus(item, !it->isDriving());
Q_EMIT onUpdateDrivingStatus(item, !it->isDriving());
}
}
@@ -547,7 +547,7 @@ void ConstraintView::updateActiveStatus()
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
if (it) {
onUpdateActiveStatus(item, !it->isActive());
Q_EMIT onUpdateActiveStatus(item, !it->isActive());
}
}
@@ -563,7 +563,7 @@ void ConstraintView::hideConstraints()
void ConstraintView::modifyCurrentItem()
{
/*emit*/itemActivated(currentItem());
Q_EMIT itemActivated(currentItem());
}
void ConstraintView::renameCurrentItem()
@@ -708,7 +708,7 @@ TaskSketcherConstraints::TaskSketcherConstraints(ViewProviderSketch *sketchView)
);
QObject::connect(
ui->visibilityButton->actions()[0], SIGNAL(changed()),
qAsConst(ui->visibilityButton)->actions()[0], SIGNAL(changed()),
this , SLOT (on_visibilityButton_trackingaction_changed())
);
@@ -1079,8 +1079,8 @@ void TaskSketcherConstraints::on_visualisationTrackingFilter_stateChanged(int st
{
QSignalBlocker block(this);
if(ui->visibilityButton->actions()[0]->isChecked() != (state == Qt::Checked))
ui->visibilityButton->actions()[0]->setChecked(state);
if (qAsConst(ui->visibilityButton)->actions()[0]->isChecked() != (state == Qt::Checked))
qAsConst(ui->visibilityButton)->actions()[0]->setChecked(state);
}
if(state == Qt::Checked)
@@ -1093,7 +1093,7 @@ void TaskSketcherConstraints::on_visibilityButton_trackingaction_changed()
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
bool visibilityTracksFilter = hGrp->GetBool("VisualisationTrackingFilter",false);
bool bstate = ui->visibilityButton->actions()[0]->isChecked();
bool bstate = qAsConst(ui->visibilityButton)->actions()[0]->isChecked();
if(visibilityTracksFilter != bstate) {
hGrp->SetBool("VisualisationTrackingFilter", bstate);

View File

@@ -240,7 +240,7 @@ void ElementView::keyPressEvent(QKeyEvent * event)
{
case Qt::Key_Z:
// signal
onFilterShortcutPressed();
Q_EMIT onFilterShortcutPressed();
break;
default:
QListWidget::keyPressEvent( event );
@@ -276,7 +276,7 @@ TaskSketcherElements::TaskSketcherElements(ViewProviderSketch *sketchView)
QString zKey = QString::fromLatin1("Z");
ui->Explanation->setText(tr("<html><head/><body><p>&quot;%1&quot;: multiple selection</p>"
"<p>&quot;%2&quot;: switch to next valid type</p></body></html>")
.arg(cmdKey).arg(zKey));
.arg(cmdKey, zKey));
ui->listWidgetElements->setSelectionMode(QAbstractItemView::ExtendedSelection);
ui->listWidgetElements->setEditTriggers(QListWidget::NoEditTriggers);
ui->listWidgetElements->setMouseTracking(true);
@@ -1128,7 +1128,7 @@ TaskSketcherElements::MultIcon::MultIcon(const char* name)
{
int hue, sat, val, alp;
Normal = Gui::BitmapFactory().iconFromTheme(name);
QImage imgConstr(Normal.pixmap(Normal.availableSizes()[0]).toImage());
QImage imgConstr(Normal.pixmap(qAsConst(Normal).availableSizes()[0]).toImage());
QImage imgExt(imgConstr);
for(int ix=0 ; ix<imgConstr.width() ; ix++) {

View File

@@ -69,7 +69,7 @@ SketcherGeneralWidget::~SketcherGeneralWidget()
bool SketcherGeneralWidget::eventFilter(QObject *object, QEvent *event)
{
if (object == ui->renderingOrder && event->type() == QEvent::ChildRemoved) {
emitRenderOrderChanged();
Q_EMIT emitRenderOrderChanged();
}
return false;
}

View File

@@ -56,7 +56,7 @@ void ViewProviderCustom::onChanged(const App::Property* prop)
}
}
}
PartGui::ViewProviderPart::onChanged(prop);
ViewProviderSketch::onChanged(prop);
}
void ViewProviderCustom::updateData(const App::Property* prop)

View File

@@ -3022,7 +3022,7 @@ void ViewProviderSketch::unsetEdit(int ModNum)
"ActiveSketch.ViewObject.TempoVis = None\n"
"del(tv)\n"
"del(ActiveSketch)\n"
).arg(QString::fromLatin1(getDocument()->getDocument()->getName())).arg(
).arg(QString::fromLatin1(getDocument()->getDocument()->getName()),
QString::fromLatin1(getSketchObject()->getNameInDocument()));
QByteArray cmdstr_bytearray = cmdstr.toLatin1();
Gui::Command::runCommand(Gui::Command::Gui, cmdstr_bytearray);
@@ -3046,7 +3046,7 @@ void ViewProviderSketch::setEditViewer(Gui::View3DInventorViewer* viewer, int Mo
" ActiveSketch.ViewObject.TempoVis.saveCamera()\n"
" if ActiveSketch.ViewObject.ForceOrtho:\n"
" ActiveSketch.ViewObject.Document.ActiveView.setCameraType('Orthographic')\n"
).arg(QString::fromLatin1(getDocument()->getDocument()->getName())).arg(
).arg(QString::fromLatin1(getDocument()->getDocument()->getName()),
QString::fromLatin1(getSketchObject()->getNameInDocument()));
QByteArray cmdstr_bytearray = cmdstr.toLatin1();
Gui::Command::runCommand(Gui::Command::Gui, cmdstr_bytearray);