summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Pratyush Yadav <me@yadavpratyush.com>2019-08-04 20:09:19 +0530
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-08-07 13:22:51 -0700
commit5440eb0ea2651c45a0e46f2335ecbb8d1f42c584 (patch)
tree1495f0e8f5ac96628fffdf5bbeef8361eadd2652
parentMerge remote-tracking branch 'philoakley/dup-gui' (diff)
downloadtgif-5440eb0ea2651c45a0e46f2335ecbb8d1f42c584.tar.xz
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>
-rwxr-xr-xgit-gui.sh19
1 files changed, 17 insertions, 2 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 5bc21b878d..09c1b3c097 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -3006,8 +3006,23 @@ unset doc_path doc_url
wm protocol . WM_DELETE_WINDOW do_quit
bind all <$M1B-Key-q> do_quit
bind all <$M1B-Key-Q> do_quit
-bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
-bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
+
+set m1b_w_script {
+ set toplvl_win [winfo toplevel %W]
+
+ # If we are destroying the main window, we should call do_quit to take
+ # care of cleanup before exiting the program.
+ if {$toplvl_win eq "."} {
+ do_quit
+ } else {
+ destroy $toplvl_win
+ }
+}
+
+bind all <$M1B-Key-w> $m1b_w_script
+bind all <$M1B-Key-W> $m1b_w_script
+
+unset m1b_w_script
set subcommand_args {}
proc usage {} {