Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Commit 0ae35d6

Browse files
committed
Include other Draft commands
1 parent e40cab8 commit 0ae35d6

File tree

8 files changed

+75
-46
lines changed

8 files changed

+75
-46
lines changed

src/Mod/Draft/draftguitools/gui_circulararray.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,15 @@ def completed(self):
124124
We should remove the callbacks that were added to the 3D view
125125
and then close the task panel.
126126
"""
127-
self.view.removeEventCallbackPivy(self.location,
128-
self.callback_move)
129-
self.view.removeEventCallbackPivy(self.mouse_event,
130-
self.callback_click)
131-
gui_utils.end_all_events()
127+
try:
128+
self.view.removeEventCallbackPivy(self.location, self.callback_move)
129+
self.view.removeEventCallbackPivy(self.mouse_event, self.callback_click)
130+
gui_utils.end_all_events()
131+
except RuntimeError:
132+
# the view has been deleted already
133+
pass
134+
self.callback_move = None
135+
self.callback_click = None
132136
if Gui.Control.activeDialog():
133137
Gui.Control.closeDialog()
134138
self.finish()

src/Mod/Draft/draftguitools/gui_orthoarray.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ def completed(self):
111111
We should remove the callbacks that were added to the 3D view
112112
and then close the task panel.
113113
"""
114-
# self.view.removeEventCallbackPivy(self.location,
115-
# self.callback_move)
116-
self.view.removeEventCallbackPivy(self.mouse_event,
117-
self.callback_click)
118-
gui_utils.end_all_events()
114+
try:
115+
self.view.removeEventCallbackPivy(self.mouse_event, self.callback_click)
116+
gui_utils.end_all_events()
117+
except RuntimeError:
118+
# the view has been deleted already
119+
pass
120+
self.callback_click = None
119121
if Gui.Control.activeDialog():
120122
Gui.Control.closeDialog()
121123
self.finish()

src/Mod/Draft/draftguitools/gui_points.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,17 @@ def finish(self, cont=False):
143143
Restart (continue) the command if `True`, or if `None` and
144144
`ui.continueMode` is `True`.
145145
"""
146-
if self.callbackClick:
147-
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
148-
if self.callbackMove:
149-
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
150-
if self.callbackClick or self.callbackMove:
151-
# Next line fixes https://github.com/FreeCAD/FreeCAD/issues/10469:
152-
gui_utils.end_all_events()
146+
try:
147+
if self.callbackClick:
148+
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
149+
if self.callbackMove:
150+
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
151+
if self.callbackClick or self.callbackMove:
152+
# Next line fixes https://github.com/FreeCAD/FreeCAD/issues/10469:
153+
gui_utils.end_all_events()
154+
except RuntimeError:
155+
# the view has been deleted already
156+
pass
153157
self.callbackClick = None
154158
self.callbackMove = None
155159
super().finish()

src/Mod/Draft/draftguitools/gui_polararray.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,15 @@ def completed(self):
124124
We should remove the callbacks that were added to the 3D view
125125
and then close the task panel.
126126
"""
127-
self.view.removeEventCallbackPivy(self.location,
128-
self.callback_move)
129-
self.view.removeEventCallbackPivy(self.mouse_event,
130-
self.callback_click)
131-
gui_utils.end_all_events()
127+
try:
128+
self.view.removeEventCallbackPivy(self.location, self.callback_move)
129+
self.view.removeEventCallbackPivy(self.mouse_event, self.callback_click)
130+
gui_utils.end_all_events()
131+
except RuntimeError:
132+
# the view has been deleted already
133+
pass
134+
self.callback_move = None
135+
self.callback_click = None
132136
if Gui.Control.activeDialog():
133137
Gui.Control.closeDialog()
134138
self.finish()

src/Mod/Draft/draftguitools/gui_snapper.py

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,13 +1385,17 @@ def cb(point):
13851385
self.view = Draft.get3DView()
13861386

13871387
# remove any previous leftover callbacks
1388-
if self.callbackClick:
1389-
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
1390-
if self.callbackMove:
1391-
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
1392-
if self.callbackClick or self.callbackMove:
1393-
# Next line fixes https://github.com/FreeCAD/FreeCAD/issues/10469:
1394-
gui_utils.end_all_events()
1388+
try:
1389+
if self.callbackClick:
1390+
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
1391+
if self.callbackMove:
1392+
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
1393+
if self.callbackClick or self.callbackMove:
1394+
# Next line fixes https://github.com/FreeCAD/FreeCAD/issues/10469:
1395+
gui_utils.end_all_events()
1396+
except RuntimeError:
1397+
# the view has been deleted already
1398+
pass
13951399
self.callbackClick = None
13961400
self.callbackMove = None
13971401

@@ -1428,13 +1432,17 @@ def click(event_cb):
14281432
accept()
14291433

14301434
def accept():
1431-
if self.callbackClick:
1432-
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
1433-
if self.callbackMove:
1434-
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
1435-
if self.callbackClick or self.callbackMove:
1436-
# Next line fixes https://github.com/FreeCAD/FreeCAD/issues/10469:
1437-
gui_utils.end_all_events()
1435+
try:
1436+
if self.callbackClick:
1437+
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
1438+
if self.callbackMove:
1439+
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
1440+
if self.callbackClick or self.callbackMove:
1441+
# Next line fixes https://github.com/FreeCAD/FreeCAD/issues/10469:
1442+
gui_utils.end_all_events()
1443+
except RuntimeError:
1444+
# the view has been deleted already
1445+
pass
14381446
self.callbackClick = None
14391447
self.callbackMove = None
14401448
Gui.Snapper.off()
@@ -1450,13 +1458,17 @@ def accept():
14501458
self.pt = None
14511459

14521460
def cancel():
1453-
if self.callbackClick:
1454-
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
1455-
if self.callbackMove:
1456-
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
1457-
if self.callbackClick or self.callbackMove:
1458-
# Next line fixes https://github.com/FreeCAD/FreeCAD/issues/10469:
1459-
gui_utils.end_all_events()
1461+
try:
1462+
if self.callbackClick:
1463+
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
1464+
if self.callbackMove:
1465+
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
1466+
if self.callbackClick or self.callbackMove:
1467+
# Next line fixes https://github.com/FreeCAD/FreeCAD/issues/10469:
1468+
gui_utils.end_all_events()
1469+
except RuntimeError:
1470+
# the view has been deleted already
1471+
pass
14601472
self.callbackClick = None
14611473
self.callbackMove = None
14621474
Gui.Snapper.off()

src/Mod/Draft/drafttaskpanels/task_circulararray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ def finish(self):
478478
the delayed functions, and perform cleanup.
479479
"""
480480
# App.ActiveDocument.commitTransaction()
481-
Gui.ActiveDocument.resetEdit()
481+
if Gui.ActiveDocument is not None:
482+
Gui.ActiveDocument.resetEdit()
482483
# Runs the parent command to complete the call
483484
self.source_command.completed()
484485

src/Mod/Draft/drafttaskpanels/task_orthoarray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ def finish(self):
386386
the delayed functions, and perform cleanup.
387387
"""
388388
# App.ActiveDocument.commitTransaction()
389-
Gui.ActiveDocument.resetEdit()
389+
if Gui.ActiveDocument is not None:
390+
Gui.ActiveDocument.resetEdit()
390391
# Runs the parent command to complete the call
391392
self.source_command.completed()
392393

src/Mod/Draft/drafttaskpanels/task_polararray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ def finish(self):
431431
the delayed functions, and perform cleanup.
432432
"""
433433
# App.ActiveDocument.commitTransaction()
434-
Gui.ActiveDocument.resetEdit()
434+
if Gui.ActiveDocument is not None:
435+
Gui.ActiveDocument.resetEdit()
435436
# Runs the parent command to complete the call
436437
self.source_command.completed()
437438

0 commit comments

Comments
 (0)