Browse Source

git-gui: Ensure all spellchecker 'class' variables are initialized

If we somehow managed to get our spellchecker instance created but
aspell wasn't startable we may not finish _connect and thus may
find one or more of our fields was not initialized in the instance.

If we have an instance but no version, there is no reason to show
a version to the user in our about dialog.  We effectively have no
spellchecker available.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
maint
Shawn O. Pearce 17 years ago
parent
commit
f57ca1efe5
  1. 3
      lib/about.tcl
  2. 14
      lib/spellcheck.tcl

3
lib/about.tcl

@ -41,7 +41,8 @@ proc do_about {} {
append v "Tcl version $tcl_patchLevel" append v "Tcl version $tcl_patchLevel"
append v ", Tk version $tk_patchLevel" append v ", Tk version $tk_patchLevel"
} }
if {[info exists ui_comm_spell]} { if {[info exists ui_comm_spell]
&& [$ui_comm_spell version] ne {}} {
append v "\n" append v "\n"
append v [$ui_comm_spell version] append v [$ui_comm_spell version]
} }

14
lib/spellcheck.tcl

@ -3,15 +3,15 @@


class spellcheck { class spellcheck {


field s_fd {} ; # pipe to aspell field s_fd {} ; # pipe to aspell
field s_version ; # aspell version string field s_version {} ; # aspell version string
field s_lang ; # current language code field s_lang {} ; # current language code


field w_text ; # text widget we are spelling field w_text ; # text widget we are spelling
field w_menu ; # context menu for the widget field w_menu ; # context menu for the widget
field s_menuidx 0 ; # last index of insertion into $w_menu field s_menuidx 0 ; # last index of insertion into $w_menu


field s_i ; # timer registration for _run callbacks field s_i {} ; # timer registration for _run callbacks
field s_clear 0 ; # did we erase mispelled tags yet? field s_clear 0 ; # did we erase mispelled tags yet?
field s_seen [list] ; # lines last seen from $w_text in _run field s_seen [list] ; # lines last seen from $w_text in _run
field s_checked [list] ; # lines already checked field s_checked [list] ; # lines already checked
@ -21,6 +21,7 @@ field s_suggest ; # array, list of suggestions, keyed by misspelling
constructor init {pipe_fd ui_text ui_menu} { constructor init {pipe_fd ui_text ui_menu} {
set w_text $ui_text set w_text $ui_text
set w_menu $ui_menu set w_menu $ui_menu
array unset s_suggest


_connect $this $pipe_fd _connect $this $pipe_fd
return $this return $this
@ -88,7 +89,10 @@ method lang {{n {}}} {
} }


method version {} { method version {} {
return "$s_version, $s_lang" if {$s_version ne {}} {
return "$s_version, $s_lang"
}
return {}
} }


method stop {} { method stop {} {

Loading…
Cancel
Save