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>
Shawn O. Pearce committed
Feb 20, 2008 at 21:48 UTC
f57ca1efe5b2e6c7ca7c2a08b0c342e2547c826c
2 files changed
+11
-6
lib/about.tcl
+2
-1
@@ -41,7 +41,8 @@ proc do_about {} {
41
append v "Tcl version $tcl_patchLevel"
42
append v ", Tk version $tk_patchLevel"
43
}
44
- if {[info exists ui_comm_spell]} {
44
+ if {[info exists ui_comm_spell]
45
+ && [$ui_comm_spell version] ne {}} {
46
append v "\n"
47
append v [$ui_comm_spell version]
48
}
lib/spellcheck.tcl
+9
-5
@@ -3,15 +3,15 @@
3
4
class spellcheck {
5
6
-field s_fd {} ; # pipe to aspell
7
-field s_version ; # aspell version string
8
-field s_lang ; # current language code
6
+field s_fd {} ; # pipe to aspell
7
+field s_version {} ; # aspell version string
8
+field s_lang {} ; # current language code
9
10
field w_text ; # text widget we are spelling
11
field w_menu ; # context menu for the widget
12
field s_menuidx 0 ; # last index of insertion into $w_menu
13
14
-field s_i ; # timer registration for _run callbacks
14
+field s_i {} ; # timer registration for _run callbacks
15
field s_clear 0 ; # did we erase mispelled tags yet?
16
field s_seen [list] ; # lines last seen from $w_text in _run
17
field s_checked [list] ; # lines already checked
@@ -21,6 +21,7 @@ field s_suggest ; # array, list of suggestions, keyed by misspelling
21
constructor init {pipe_fd ui_text ui_menu} {
22
set w_text $ui_text
23
set w_menu $ui_menu
24
+ array unset s_suggest
25
26
_connect $this $pipe_fd
27
return $this
@@ -88,7 +89,10 @@ method lang {{n {}}} {
89
}
90
91
method version {} {
91
- return "$s_version, $s_lang"
92
+ if {$s_version ne {}} {
93
+ return "$s_version, $s_lang"
94
+ }
95
+ return {}
96
}
97
98
method stop {} {