Skip to content

Commit db733ff

Browse files
committed
Call ExitApp in HandleExit only to override the exit code
1 parent 91d34f8 commit db733ff

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ahkpy/Python.ahk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,9 @@ GuiClose:
627627
return
628628

629629
HandleExit(reason, code, label:="OnExit") {
630-
; Delete all custom menu items so that Python menu callbacks are freed.
630+
; Delete all custom menus so that Python menu callbacks are not referenced
631+
; by the menu items. Not doing so prevents the application from exitting
632+
; correctly.
631633
for menuName, _ in MENUS {
632634
try {
633635
Menu, %menuName%, DeleteAll
@@ -639,6 +641,6 @@ HandleExit(reason, code, label:="OnExit") {
639641

640642
if (Py_FinalizeEx() < 0) {
641643
code := 120
644+
ExitApp, %code%
642645
}
643-
ExitApp, %code%
644646
}

0 commit comments

Comments
 (0)