Skip to content

Commit eb859df

Browse files
committed
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>
1 parent 009409f commit eb859df

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

gitk

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9819,8 +9819,10 @@ proc showrefs {} {
98199819
-width 30 -height 20 -cursor $maincursor \
98209820
-spacing1 1 -spacing3 1 -state disabled
98219821
$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+
}
98249826
${NS}::scrollbar $top.ysb -command "$top.list yview" -orient vertical
98259827
${NS}::scrollbar $top.xsb -command "$top.list xview" -orient horizontal
98269828
grid $top.list $top.ysb -sticky nsew
@@ -11532,7 +11534,9 @@ proc choosecolor {v vi w x cmd} {
1153211534
proc setselbg {c} {
1153311535
global bglist cflist
1153411536
foreach w $bglist {
11535-
$w configure -selectbackground $c
11537+
if {[winfo exists $w]} {
11538+
$w configure -selectbackground $c
11539+
}
1153611540
}
1153711541
$cflist tag configure highlight \
1153811542
-background [$cflist cget -selectbackground]
@@ -11558,15 +11562,19 @@ proc setbg {c} {
1155811562
global bglist
1155911563

1156011564
foreach w $bglist {
11561-
$w conf -background $c
11565+
if {[winfo exists $w]} {
11566+
$w conf -background $c
11567+
}
1156211568
}
1156311569
}
1156411570

1156511571
proc setfg {c} {
1156611572
global fglist canv
1156711573

1156811574
foreach w $fglist {
11569-
$w conf -foreground $c
11575+
if {[winfo exists $w]} {
11576+
$w conf -foreground $c
11577+
}
1157011578
}
1157111579
allcanvs itemconf text -fill $c
1157211580
$canv itemconf circle -outline $c

0 commit comments

Comments
 (0)