git-gui: call do_quit before destroying the main window
If the toplevel window for the window being destroyed is the main window (aka "."), then simply destroying it means the cleanup tasks are not executed (like saving the commit message buffer, saving window state, etc.) All this is handled by do_quit. Call it instead of directly destroying the main window. For other toplevel windows, the old behavior remains. Signed-off-by: Pratyush Yadav <me@yadavpratyush.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pratyush Yadav committed
Aug 4, 2019 at 20:09 UTC
5440eb0ea2651c45a0e46f2335ecbb8d1f42c584
1 file changed
+17
-2
git-gui.sh
+17
-2
@@ -3006,8 +3006,23 @@ unset doc_path doc_url
3006
wm protocol . WM_DELETE_WINDOW do_quit
3007
bind all <$M1B-Key-q> do_quit
3008
bind all <$M1B-Key-Q> do_quit
3009
-bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
3010
-bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
3009
+
3010
+set m1b_w_script {
3011
+ set toplvl_win [winfo toplevel %W]
3012
+
3013
+ # If we are destroying the main window, we should call do_quit to take
3014
+ # care of cleanup before exiting the program.
3015
+ if {$toplvl_win eq "."} {
3016
+ do_quit
3017
+ } else {
3018
+ destroy $toplvl_win
3019
+ }
3020
+}
3021
+
3022
+bind all <$M1B-Key-w> $m1b_w_script
3023
+bind all <$M1B-Key-W> $m1b_w_script
3024
+
3025
+unset m1b_w_script
3026
3027
set subcommand_args {}
3028
proc usage {} {