benini / scid

Other
43 stars 12 forks source link

Fixed two startup/event race conditions. #162

Open scidfork opened 7 months ago

scidfork commented 7 months ago

Just a couple quick fixes to some corner cases I ran across.

1) Clicking on a board square at startup could generate a call to playerCanMove before fics exists, popping up an error message. Fixed by adding a check that .fics exists first, as is done in other places within that file.

2) Clicking/holding the title bar at startup, before the spellcheck file loads, can no longer result in a crash to terminal due to a progressWindow grab attempt before it is viewable. There were other triggers for this same issue such as occasionally opening a menu at the right moment during startup. Kept hitting this once every so often, prior to adding the update idletasks before the grab.

2a) Finally, added a catch to the progressWindow's grab call. Found that there were still some scenarios at startup where the grab could still fail with "grab failed: another application has grab." For example, on my OS (linux) seemed that highlighting something in the terminal after starting scid would trigger this issue. Outside of startup I could not trigger this particular issue on any other grab calls.

benini commented 7 months ago

'Update idletasks' can be dangerous because it exhibits different behaviors on various operating systems. Generally, it is safe to use after making changes in a window to immediately reflect those changes. However, this approach can also be tricky. Therefore, it is better to avoid its use, especially in a function like 'progressWindow' that is utilized in numerous places.

The line that loads the spellcheck files: https://github.com/benini/scid/blob/github/tcl/end.tcl#L1191 is just before an "after 1 {}" block. Could you please try moving the code inside that block to see if it resolves the issue?