From 822146b169079ae351d8bcced6ac5512dc44359a Mon Sep 17 00:00:00 2001 From: scidfork Date: Mon, 29 Jan 2024 20:26:31 -0600 Subject: [PATCH 1/2] Fixed two startup/event race conditions. 1) Clicking on a board square at startup can no longer generate a call to playerCanMove before fics exists. 2) Clicking/holding the title bar at startup, before the spellcheck file loads, no longer results in a crash to terminal due to a progressWindow grab attempt before it is viewable. 2a) In the event that another application already has grab, also added catch to the grab call. --- tcl/main.tcl | 4 +++- tcl/misc.tcl | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tcl/main.tcl b/tcl/main.tcl index bb0a57fd7..176d8ba03 100644 --- a/tcl/main.tcl +++ b/tcl/main.tcl @@ -1020,7 +1020,9 @@ proc leaveSquare { square } { proc pressSquare { square } { global selectedSq highcolor - if { ![::fics::playerCanMove] } { return } ;# not player's turn + if { [winfo exists .fics] } { + if { ![::fics::playerCanMove] } { return } ;# not player's turn + } # if training with calculations of var is on, just log the event if { [winfo exists .calvarWin] } { diff --git a/tcl/misc.tcl b/tcl/misc.tcl index 574e218a1..99b558dc9 100644 --- a/tcl/misc.tcl +++ b/tcl/misc.tcl @@ -321,7 +321,8 @@ proc progressWindow { title text {button ""} {command "progressBarCancel"} } { set x [expr ([winfo screenwidth $w] - 400) / 2] set y [expr ([winfo screenheight $w] - 40) / 2] wm geometry $w +$x+$y - grab $w + update idletasks + catch { grab $w } wm withdraw $w progressBarSet $w.f.c 401 21 From 7e4cebc11e9530d4d63aad07722d632d6647de09 Mon Sep 17 00:00:00 2001 From: Fulvio Benini Date: Tue, 30 Jan 2024 11:21:33 +0100 Subject: [PATCH 2/2] Avoid fixed window names. --- tcl/main.tcl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tcl/main.tcl b/tcl/main.tcl index 176d8ba03..6c3f663fa 100644 --- a/tcl/main.tcl +++ b/tcl/main.tcl @@ -1020,9 +1020,7 @@ proc leaveSquare { square } { proc pressSquare { square } { global selectedSq highcolor - if { [winfo exists .fics] } { - if { ![::fics::playerCanMove] } { return } ;# not player's turn - } + if {[info procs ::fics::playerCanMove] ne "" && ![::fics::playerCanMove]} { return } ;# not player's turn # if training with calculations of var is on, just log the event if { [winfo exists .calvarWin] } {