Skip to content

Commit

Permalink
git-gui: Catch and display aspell startup failures to the user
Browse files Browse the repository at this point in the history
If we feed a bad dictionary name to aspell on startup it may appear
to start (as Tcl found the executable in our $PATH) but it fails to
give us the version string.  In such a case the close of the pipe
will report the exit status of the process (failure) and that is
an error in Tcl.

We now trap the subprocess failure and display the stderr message
from it, letting the user know why the failure is happening.  We then
disable the spell checker, but keep our object instance so the user
can alter their preferred dictionary through the options dialog, and
possibly restart the spell checker.

I was also originally wrong to use "error" here for the display
of the problem to the user.  I meant to use "error_popup", which
will open a message box and show the failure in a GUI context,
rather than killing git-gui and showing the message on the console.

Noticed by Ilari on #git.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
  • Loading branch information
Shawn O. Pearce committed Feb 21, 2008
1 parent 35d04b3 commit de83f8c
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/spellcheck.tcl
Original file line number Diff line number Diff line change
@@ -35,12 +35,25 @@ method _connect {pipe_fd} {
-translation lf

if {[gets $pipe_fd s_version] <= 0} {
close $pipe_fd
error [mc "Spell checker sliently failed on startup"]
if {[catch {close $pipe_fd} err]} {
regsub -nocase {^Error: } $err {} err
if {$s_fd eq {}} {
error_popup [strcat [mc "Spell checking is unavailable"] ":\n\n$err"]
} else {
error_popup [strcat \
[mc "Invalid spell checking configuration"] \
":\n\n$err\n\n" \
[mc "Reverting dictionary to %s." $s_lang]]
}
} else {
error_popup [mc "Spell checker sliently failed on startup"]
}
return
}
if {{@(#) } ne [string range $s_version 0 4]} {
close $pipe_fd
error [strcat [mc "Unrecognized spell checker"] ": $s_version"]
catch {close $pipe_fd}
error_popup [strcat [mc "Unrecognized spell checker"] ":\n\n$s_version"]
return
}
set s_version [string range $s_version 5 end]

0 comments on commit de83f8c

Please sign in to comment.