From a683f3aca4042b64d6d1d47eede5b4df6cd9a3ac Mon Sep 17 00:00:00 2001 From: Paddle Date: Sun, 27 Aug 2023 09:26:44 +0200 Subject: [PATCH] Fix crash when user click 'Close' button while Dimension is active. TaskDlgEditSketch didn't purge the handler first as is doing CmdSketcherLeaveSketch. --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 1 - src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 61452d0d4a..a9acd51be9 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -1061,7 +1061,6 @@ public: void deactivated() override { Gui::Command::abortCommand(); - //TODO: When user exit sketch edit while tool is activated solve() crashes. solve is needed to refresh the sketch after abortCommand Obj->solve(); sketchgui->draw(false, false); // Redraw } diff --git a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp index 0912c4b54b..02a530d51f 100644 --- a/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp +++ b/src/Mod/Sketcher/Gui/TaskDlgEditSketch.cpp @@ -100,6 +100,10 @@ bool TaskDlgEditSketch::reject() hGrp->SetBool("ExpandedConstraintsWidget", Constraints->isGroupVisible()); hGrp->SetBool("ExpandedElementsWidget", Elements->isGroupVisible()); + if (sketchView && sketchView->getSketchMode() != ViewProviderSketch::STATUS_NONE) { + sketchView->purgeHandler(); + } + std::string document = getDocumentName();// needed because resetEdit() deletes this instance Gui::Command::doCommand( Gui::Command::Gui, "Gui.getDocument('%s').resetEdit()", document.c_str());