git-gui: ensure correct application termination in git-gui--askpass
With Tk 8.5 the askpass utility can hang waiting for the wish shell implicit event loop to exit. This patch uses an explicit event loop to ensure correct application termination. Reported-by: Anders Kaseorg <andersk@mit.edu> Tested-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Pat Thoyts committed
Aug 18, 2010 at 23:19 UTC
aef0b48ef05b5980d2f3a1e4bc14b70d9688d59b
1 file changed
+13
-6
git-gui--askpass
+13
-6
@@ -5,6 +5,8 @@ exec wish "$0" -- "$@"
5
# This is a trivial implementation of an SSH_ASKPASS handler.
6
# Git-gui uses this script if none are already configured.
7
8
+package require Tk
9
+
10
set answer {}
11
set yesno 0
12
set rc 255
@@ -30,16 +32,20 @@ if {!$yesno} {
32
33
frame .b
34
button .b.ok -text OK -command finish
33
-button .b.cancel -text Cancel -command {destroy .}
35
+button .b.cancel -text Cancel -command cancel
36
37
pack .b.ok -side left -expand 1
38
pack .b.cancel -side right -expand 1
39
pack .b -side bottom -fill x -padx 10 -pady 10
40
41
bind . <Visibility> {focus -force .e}
40
-bind . <Key-Return> finish
41
-bind . <Key-Escape> {destroy .}
42
-bind . <Destroy> {exit $rc}
42
+bind . <Key-Return> [list .b.ok invoke]
43
+bind . <Key-Escape> [list .b.cancel invoke]
44
+bind . <Destroy> {set rc $rc}
45
+
46
+proc cancel {} {
47
+ set ::rc 255
48
+}
49
50
proc finish {} {
51
if {$::yesno} {
@@ -50,10 +56,11 @@ proc finish {} {
56
}
57
}
58
53
- set ::rc 0
59
puts $::answer
55
- destroy .
60
+ set ::rc 0
61
}
62
63
wm title . "OpenSSH"
64
tk::PlaceWindow .
65
+vwait rc
66
+exit $rc