benini / scid

Other
43 stars 12 forks source link

Load at startup not honoured #107

Closed nicktmro closed 1 year ago

nicktmro commented 1 year ago

Summary: the Load at startup toggle is not honoured between restarts of the app.

Environment SCID Version 5.0.0, Jan 27 2023 running on macOS Ventura, Using Tcl/Tk version: 8.6.13 Tcl(8.6.13), TclOO(1.1.0), Tk(8.6.13), Ttk(8.6.13), ezsmtp(1.0.0), msgcat(1.6.1), opt(0.4.8), tcl::tommath(8.6.13), tooltip(1.4.6), ttk::theme::alt(8.6), ttk::theme::aqua(8.6), ttk::theme::clam(8.6), ttk::theme::classic(8.6), ttk::theme::default(8.6), zlib(2.0.1).

Steps to reproduce:

  1. Load a database from disk
  2. Right click on the database and toggle Load at startup Load at startup is selected
  3. Restart SCID

Expected result:

Actual result:

nicktmro commented 1 year ago

I don't know if it helps, but it appears the history.dat file is not being updated and saved, either. I am mentioning this because I noticed in the ::file::Exit an attempt to save the history, too, and despite the fact I do heaps of searches and edits in comboboxes the values I previously entered to not persist between app restarts (they do show up within the same session, however).

benini commented 1 year ago

I cannot reproduce this (it works as expected with macos12 in a VM). I can just give you a couple of suggestion: 1) Maybe it depends on filenames? Try to autoload a simple.pgn and check if both the full absolute path of simple.pgn and recent.dat have "strange" characters. 2) The recent.dat is written in the end when the program is closed ( https://github.com/benini/scid/blob/github/tcl/file.tcl#L45 ). You can try to save it immediately when scid is closed adding ::recentFiles::save true as line 6 just after proc ::file::Exit

nicktmro commented 1 year ago

Thank you for your reply. You have helped me identify the scenario in which this happens.

On macOS, users are accustomed to using Cmd + Q to quit apps. It seems that when using this keyboard shortcut the ::file::Exit proc is not invoked.

Using the File > Quit menu entry, however, does invoke the ::file::Exit proc and the saving / dumping of the in-memory content is done correctly.

IMHO, it would be preferable to save to disk the user's settings as they are made, rather than waiting until the app is terminated. This may help restore sessions when the app crashes, for example, too.

nicktmro commented 1 year ago

I was able to add this event to trap the Mac specific quit event in the menus.tcl and now the Quitting is working as expected.

proc ::tk::mac::Quit {args} { ::file::Exit }

Please let me know if you'd like me to submit a PR? I wasn't sure if this is where the proc belongs logically, so I thought I'd ask first and save you some time. More than happy for you to made the edit directly, of course!

benini commented 1 year ago

Thanks, great job. I have pushed the commit: https://github.com/benini/scid/commit/e3b585738ae8f572c4f1af57691cfd1f59ff2c45

Feel free to open pull requests in the future, we can always discuss eventual changes before merging.