gitk: Fix error when changing colors after closing "List references" window
This fixes an error that manifests itself if the user opens the "List references" window and the closes it, and subsequently opens the Preferences window and changes one of the colors. When the user clicks OK, and error popup appears with the message: Error: invalid command name ".showrefs.list" This is because .showrefs.list was added to the list of windows to be notified on foreground/background color changes, but the window no longer exists. We fix the bug by checking whether the window exists before trying to change its colors. As an optimization, we also avoid adding the .showrefs.list window to the list a second time. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
May 3, 2015 at 15:11 UTC
eb859df85e480ae4aa76a0d8358054b10d91749c
1 file changed
+13
-5
gitk
+13
-5
@@ -9819,8 +9819,10 @@ proc showrefs {} {
9819
-width 30 -height 20 -cursor $maincursor \
9820
-spacing1 1 -spacing3 1 -state disabled
9821
$top.list tag configure highlight -background $selectbgcolor
9822
- lappend bglist $top.list
9823
- lappend fglist $top.list
9822
+ if {![lsearch -exact $bglist $top.list]} {
9823
+ lappend bglist $top.list
9824
+ lappend fglist $top.list
9825
+ }
9826
${NS}::scrollbar $top.ysb -command "$top.list yview" -orient vertical
9827
${NS}::scrollbar $top.xsb -command "$top.list xview" -orient horizontal
9828
grid $top.list $top.ysb -sticky nsew
@@ -11532,7 +11534,9 @@ proc choosecolor {v vi w x cmd} {
11534
proc setselbg {c} {
11535
global bglist cflist
11536
foreach w $bglist {
11535
- $w configure -selectbackground $c
11537
+ if {[winfo exists $w]} {
11538
+ $w configure -selectbackground $c
11539
+ }
11540
}
11541
$cflist tag configure highlight \
11542
-background [$cflist cget -selectbackground]
@@ -11558,7 +11562,9 @@ proc setbg {c} {
11562
global bglist
11563
11564
foreach w $bglist {
11561
- $w conf -background $c
11565
+ if {[winfo exists $w]} {
11566
+ $w conf -background $c
11567
+ }
11568
}
11569
}
11570
@@ -11566,7 +11572,9 @@ proc setfg {c} {
11572
global fglist canv
11573
11574
foreach w $fglist {
11569
- $w conf -foreground $c
11575
+ if {[winfo exists $w]} {
11576
+ $w conf -foreground $c
11577
+ }
11578
}
11579
allcanvs itemconf text -fill $c
11580
$canv itemconf circle -outline $c