benini / scid

Other
44 stars 15 forks source link

Fixed errors from closing Resources window when a child window is open. #165

Closed scidfork closed 10 months ago

scidfork commented 10 months ago

Found that error messages could be generated when closing the Resources window while any one of a number of possible child windows were open. These being either generated by tk_getOpenFile or tk_chooseDirectory.

Additionally, in those cases where additional processing occurs after the selection (spellcheck, photos, theme, eco, and sounds) and additional check is added before updating the path entry, as the user could also close the Resources window before acknowledging the popup message that these selections generate.

benini commented 10 months ago

It should not be possible to close the window while a child window exists. Probably adding something like:

wm protocol $w WM_DELETE_WINDOW [list apply {{w} {
     if {[grab current $w] eq $w} {
        destroy $w
     }
}} $w]

or (assuming the child windows cancel the operation in response to a destroy):

wm protocol $w WM_DELETE_WINDOW [list apply {{w} {
    set current_grab [grab current $w]
    if {$current_grab ne $w} { destroy $current_grab }
    destroy $w
}} $w]
scidfork commented 10 months ago

Indeed, that is a much cleaner approach. Especially the first option, as that's a "once and done" solution. I've gone ahead with the formality of updating this branch, but I think it's hardly worth pushing the first commit into the project history given the complete undo. Your certainly welcome to just close this and make the change directly, or I can push a clean branch to pull.

benini commented 10 months ago

That's ok, I'll just click the lovely github's button squash and merge