Draft: Stop draftToolBar.escape() executing multiple times

Fixes #17027.

The `DraftTaskPanel.reject()` function can be called multiple times if Esc is pressed during a fast mouse move. We need to prevent multiple calls to `draftToolBar.escape()` as this will lead to multiple calls to `gui_utils.end_all_events()` which results in a crash.
This commit is contained in:
Roy-043
2024-10-07 09:52:35 +02:00
committed by Yorik van Havre
parent fc7044350c
commit 6ccca8b9ad

View File

@@ -140,6 +140,12 @@ class DraftTaskPanel:
FreeCADGui.ActiveDocument.resetEdit()
return True
def reject(self):
# https://github.com/FreeCAD/FreeCAD/issues/17027
# Function can be called multiple times if Esc is pressed during mouse
# move. We need to prevent multiple calls to draftToolBar.escape():
if getattr(FreeCAD, "activeDraftCommand", None) is None:
return
FreeCAD.activeDraftCommand = None
FreeCADGui.draftToolBar.isTaskOn = False
FreeCADGui.draftToolBar.escape()
if FreeCADGui.ActiveDocument: