Sketcher: [skip ci] do not create dialog on heap if not needed to improve exception-safety and reduce possible memory leaks

This commit is contained in:
wmayer
2020-10-22 16:01:22 +02:00
parent ae33d9eb91
commit 731f89ccbf
2 changed files with 11 additions and 18 deletions

View File

@@ -775,21 +775,15 @@ void CmdSketcherMirrorSketch::activated(int iMsg)
return;
}
// Ask the user the type of mirroring
SketchMirrorDialog * smd = new SketchMirrorDialog();
int refgeoid = -1;
Sketcher::PointPos refposid = Sketcher::none;
if (smd->exec() == QDialog::Accepted) {
refgeoid = smd->RefGeoid;
refposid = smd->RefPosid;
delete smd;
}
else {
delete smd;
// Ask the user the type of mirroring
SketchMirrorDialog smd;
if (smd.exec() != QDialog::Accepted)
return;
}
refgeoid = smd.RefGeoid;
refposid = smd.RefPosid;
App::Document* doc = App::GetApplication().getActiveDocument();
openCommand("Create a mirrored sketch for each selected sketch");

View File

@@ -1887,15 +1887,14 @@ void CmdSketcherRectangularArray::activated(int iMsg)
}
// Pop-up asking for values
SketchRectangularArrayDialog * slad = new SketchRectangularArrayDialog();
SketchRectangularArrayDialog slad;
if (slad->exec() == QDialog::Accepted) {
if (slad.exec() == QDialog::Accepted) {
ActivateAcceleratorHandler(getActiveGuiDocument(),
new DrawSketchHandlerRectangularArray(geoIdList, LastGeoId, LastPointPos, geoids, slad->Clone,
slad->Rows, slad->Cols, slad->ConstraintSeparation,
slad->EqualVerticalHorizontalSpacing));
new DrawSketchHandlerRectangularArray(geoIdList, LastGeoId, LastPointPos, geoids, slad.Clone,
slad.Rows, slad.Cols, slad.ConstraintSeparation,
slad.EqualVerticalHorizontalSpacing));
}
delete slad;
}
bool CmdSketcherRectangularArray::isActive(void)