Merge pull request #20754 from hyarion/coverty/sketchobject

Sketcher: Fix some of the coverity issues in SketchObject.cpp
This commit is contained in:
Kacper Donat
2025-05-05 19:28:55 +02:00
committed by GitHub
2 changed files with 13 additions and 13 deletions

View File

@@ -426,7 +426,7 @@ const std::map<std::string,std::string> SketchObject::getInternalElementMap() co
if (!internalElementMap.empty() || !MakeInternals.getValue())
return internalElementMap;
auto internalShape = InternalShape.getShape();
const auto& internalShape = InternalShape.getShape();
auto shape = Shape.getShape().located(TopLoc_Location());
if (!internalShape.isNull() && !shape.isNull()) {
std::vector<std::string> names;
@@ -1142,7 +1142,7 @@ void SketchObject::reverseAngleConstraintToSupplementary(Constraint* constr, int
// Edit the expression if any, else modify constraint value directly
if (constraintHasExpression(constNum)) {
std::string expression = getConstraintExpression(constNum);
setConstraintExpression(constNum, reverseAngleConstraintExpression(expression));
setConstraintExpression(constNum, std::move(reverseAngleConstraintExpression(expression)));
}
else {
double actAngle = constr->getValue();
@@ -1185,7 +1185,7 @@ void SketchObject::setConstraintExpression(int constNum, const std::string& newE
if (info.expression) {
try {
std::shared_ptr<App::Expression> expr(App::Expression::parse(this, newExpression));
setExpression(path, expr);
setExpression(path, std::move(expr));
}
catch (const Base::Exception&) {
Base::Console().Error("Failed to set constraint expression.");
@@ -1353,7 +1353,7 @@ int SketchObject::diagnoseAdditionalConstraints(
return lastDoF;
}
int SketchObject::moveGeometries(std::vector<GeoElementId> geoEltIds, const Base::Vector3d& toPoint, bool relative,
int SketchObject::moveGeometries(const std::vector<GeoElementId>& geoEltIds, const Base::Vector3d& toPoint, bool relative,
bool updateGeoBeforeMoving)
{
@@ -1935,7 +1935,7 @@ int SketchObject::delGeometriesExclusiveList(const std::vector<int>& GeoIds)
void SketchObject::replaceGeometries(std::vector<int> oldGeoIds,
std::vector<Part::Geometry*>& newGeos)
{
auto vals = getInternalGeometry();
auto& vals = getInternalGeometry();
auto newVals(vals);
if (std::any_of(oldGeoIds.begin(), oldGeoIds.end(), [](auto geoId) {
@@ -2493,7 +2493,7 @@ void SketchObject::transferFilletConstraints(int geoId1, PointPos posId1, int ge
}
}
}
delConstraints(deleteme, false);
delConstraints(std::move(deleteme), false);
return;
}
@@ -3449,7 +3449,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
addConstraint(std::move(newConstr));
};
delConstraints(idsOfOldConstraints, false);
delConstraints(std::move(idsOfOldConstraints), false);
if (!isOriginalCurvePeriodic) {
transferConstraints(GeoId, PointPos::start, newIds.front(), PointPos::start, true);
@@ -3808,7 +3808,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d& point)
solve();
}
delConstraints(idsOfOldConstraints);
delConstraints(std::move(idsOfOldConstraints));
addConstraints(newConstraints);
for (auto& cons : newConstraints) {
@@ -7083,7 +7083,7 @@ int SketchObject::carbonCopy(App::DocumentObject* pObj, bool construction)
*
* if (expr_info.expression)*/
// App::Expression * expr = parse(this, const std::string& buffer);
setExpression(Constraints.createPath(nextcid), expr);
setExpression(Constraints.createPath(nextcid), std::move(expr));
}
}
}
@@ -9262,7 +9262,7 @@ const std::vector<std::map<int, Sketcher::PointPos>> SketchObject::getCoincidenc
std::map<int, Sketcher::PointPos> tmp;
tmp.insert(std::pair<int, Sketcher::PointPos>(constr->First, constr->FirstPos));
tmp.insert(std::pair<int, Sketcher::PointPos>(constr->Second, constr->SecondPos));
coincidenttree.push_back(tmp);
coincidenttree.push_back(std::move(tmp));
}
else if (firstpresentin != -1) {
// add to existing group
@@ -11072,7 +11072,7 @@ std::vector<const char *> SketchObject::getElementTypes(bool all) const
void SketchObject::setExpression(const App::ObjectIdentifier& path,
std::shared_ptr<App::Expression> expr)
{
DocumentObject::setExpression(path, expr);
DocumentObject::setExpression(path, std::move(expr));
if (noRecomputes) {
// if we do not have a recompute, the sketch must be solved to update the DoF of the solver,
@@ -11589,7 +11589,7 @@ int SketchObject::renameConstraint(int GeoId, std::string name)
Base::StateLocker lock(managedoperation, true);
Constraint* copy = item->clone();
copy->Name = name;
copy->Name = std::move(name);
Constraints.set1Value(GeoId, copy);
delete copy;

View File

@@ -354,7 +354,7 @@ public:
/// toggle the driving status of this constraint
int toggleVirtualSpace(int ConstrId);
/// move this point to a new location and solve
int moveGeometries(std::vector<GeoElementId> geoEltIds,
int moveGeometries(const std::vector<GeoElementId>& geoEltIds,
const Base::Vector3d& toPoint,
bool relative = false,
bool updateGeoBeforeMoving = false);