Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Sketcher: [skip ci] do not create dialog on heap if not needed to imp…
…rove exception-safety and reduce possible memory leaks
  • Loading branch information
wwmayer committed Oct 22, 2020
1 parent 8b983e6 commit cd4901b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
18 changes: 6 additions & 12 deletions src/Mod/Sketcher/Gui/Command.cpp
Expand Up @@ -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");
Expand Down
11 changes: 5 additions & 6 deletions src/Mod/Sketcher/Gui/CommandSketcherTools.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit cd4901b

Please sign in to comment.