Coverity: Resource leak
This commit is contained in:
@@ -49,7 +49,7 @@ public:
|
||||
/// set the FemMesh shape
|
||||
void setValue(const FemMesh&);
|
||||
/// does nothing, for add property macro
|
||||
void setValue(void){};
|
||||
void setValue(void){}
|
||||
/// get the FemMesh shape
|
||||
const FemMesh &getValue(void) const;
|
||||
const Data::ComplexGeoData* getComplexData() const;
|
||||
|
||||
@@ -591,9 +591,9 @@ App::DocumentObject* FemVTKTools::readResult(const char* filename, App::Document
|
||||
}
|
||||
|
||||
App::DocumentObject* mesh = pcDoc->addObject("Fem::FemMeshObject", "ResultMesh");
|
||||
FemMesh* fmesh = new FemMesh(); // PropertyFemMesh instance is responsible to release FemMesh ??
|
||||
importVTKMesh(dataset, fmesh);
|
||||
static_cast<PropertyFemMesh*>(mesh->getPropertyByName("FemMesh"))->setValue(*fmesh);
|
||||
std::unique_ptr<FemMesh> fmesh(new FemMesh());
|
||||
importVTKMesh(dataset, fmesh.get());
|
||||
static_cast<PropertyFemMesh*>(mesh->getPropertyByName("FemMesh"))->setValuePtr(fmesh.release());
|
||||
static_cast<App::PropertyLink*>(result->getPropertyByName("Mesh"))->setValue(mesh);
|
||||
// PropertyLink is the property type to store DocumentObject pointer
|
||||
|
||||
|
||||
@@ -356,7 +356,9 @@ void SketchAnalysis::makeMissingPointOnPointCoincident(bool onebyone)
|
||||
c->SecondPos = it->SecondPos;
|
||||
|
||||
if(onebyone) {
|
||||
// addConstraint() creates a clone
|
||||
sketch->addConstraint(c);
|
||||
delete c;
|
||||
|
||||
solvesketch(status,dofs,true);
|
||||
|
||||
@@ -435,7 +437,9 @@ void SketchAnalysis::makeMissingVerticalHorizontal(bool onebyone)
|
||||
c->SecondPos = it->SecondPos;
|
||||
|
||||
if(onebyone) {
|
||||
// addConstraint() creates a clone
|
||||
sketch->addConstraint(c);
|
||||
delete c;
|
||||
|
||||
solvesketch(status,dofs,true);
|
||||
|
||||
@@ -630,7 +634,9 @@ void SketchAnalysis::makeMissingEquality(bool onebyone)
|
||||
c->SecondPos = it->SecondPos;
|
||||
|
||||
if(onebyone) {
|
||||
// addConstraint() creates a clone
|
||||
sketch->addConstraint(c);
|
||||
delete c;
|
||||
|
||||
solvesketch(status,dofs,true);
|
||||
|
||||
|
||||
@@ -1379,7 +1379,7 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG
|
||||
// Nothing guarantees that a tangent can be freely transferred to another coincident point, as
|
||||
// the transfer destination edge most likely won't be intended to be tangent. However, if it is
|
||||
// an end to end point tangency, the user expects it to be substituted by a coincidence constraint.
|
||||
Constraint *constNew = newVals[i]->clone();
|
||||
std::unique_ptr<Constraint> constNew(newVals[i]->clone());
|
||||
constNew->First = toGeoId;
|
||||
constNew->FirstPos = toPosId;
|
||||
|
||||
@@ -1396,14 +1396,15 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG
|
||||
continue;
|
||||
}
|
||||
|
||||
newVals[i] = constNew;
|
||||
changed.push_back(constNew);
|
||||
Constraint* constPtr = constNew.release();
|
||||
newVals[i] = constPtr;
|
||||
changed.push_back(constPtr);
|
||||
}
|
||||
else if (vals[i]->Second == fromGeoId && vals[i]->SecondPos == fromPosId &&
|
||||
!(vals[i]->First == toGeoId && vals[i]->FirstPos == toPosId) &&
|
||||
!(toGeoId < 0 && vals[i]->First< 0)) {
|
||||
|
||||
Constraint *constNew = newVals[i]->clone();
|
||||
std::unique_ptr<Constraint> constNew(newVals[i]->clone());
|
||||
constNew->Second = toGeoId;
|
||||
constNew->SecondPos = toPosId;
|
||||
// Nothing guarantees that a tangent can be freely transferred to another coincident point, as
|
||||
@@ -1416,8 +1417,9 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG
|
||||
continue;
|
||||
}
|
||||
|
||||
newVals[i] = constNew;
|
||||
changed.push_back(constNew);
|
||||
Constraint* constPtr = constNew.release();
|
||||
newVals[i] = constPtr;
|
||||
changed.push_back(constPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user