sim: Persist calculator state on exit#1689
Closed
alsrgv wants to merge 1 commit into
Closed
Conversation
c3d
requested changes
May 8, 2026
| // under the app data dir; QDir::setCurrent() is already pointed there. | ||
| { | ||
| char existing[256] = { 0 }; | ||
| if (ui_read_setting("state", existing, sizeof(existing)) == 0) |
Owner
There was a problem hiding this comment.
Suggested change
| if (ui_read_setting("state", existing, sizeof(existing)) == 0) | |
| if (ui_read_setting("state", nullptr, 0) == 0) |
| // (it's a no-op when no path has been configured). The file lives | ||
| // under the app data dir; QDir::setCurrent() is already pointed there. | ||
| { | ||
| char existing[256] = { 0 }; |
Owner
There was a problem hiding this comment.
That is not necessary with the suggestion below, you don't care about the value.
Author
There was a problem hiding this comment.
I didn't realize value could be null - thanks for the feedback! Updated.
The simulator already saves its state on EXIT_PGM (see src/dmcp/main.cc), but only when a state-file path has previously been configured by the user via the SETUP > State > Save menu. On a fresh install the path is empty, so closing the window silently discards all settings (Beep mode, display options, etc.) and stack contents. Default the persisted state-file path to "state/<PROGRAM_NAME>.48S" on first launch, so that exit reliably writes a state file and the next launch reliably restores it. Also honor STATE_IO_SILENT in state_load_callback. With the default path set, the first launch (when no state file exists yet) was popping up a "State load failed: No such file or directory" dialog; silent loads should be silent on missing files too. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alex Sergeev <alexander.sergeev@live.com>
096d06c to
0142508
Compare
Owner
|
Thanks @alsrgv, I pushed your fix on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The simulator already saves its state on EXIT_PGM (see src/dmcp/main.cc), but only when a state-file path has previously been configured by the user via the SETUP > State > Save menu. On a fresh install the path is empty, so closing the window silently discards all settings (Beep mode, display options, etc.) and stack contents.
Default the persisted state-file path to "state/<PROGRAM_NAME>.48S" on first launch, so that exit reliably writes a state file and the next launch reliably restores it.
Also honor STATE_IO_SILENT in state_load_callback. With the default path set, the first launch (when no state file exists yet) was popping up a "State load failed: No such file or directory" dialog; silent loads should be silent on missing files too.