Skip to content

Treat save-changes dialog dismissal as Cancel instead of No#11985

Merged
niksedk merged 2 commits into
SubtitleEdit:mainfrom
pdjdev:fix/save-changes-dialog-close-as-cancel
Jun 29, 2026
Merged

Treat save-changes dialog dismissal as Cancel instead of No#11985
niksedk merged 2 commits into
SubtitleEdit:mainfrom
pdjdev:fix/save-changes-dialog-close-as-cancel

Conversation

@pdjdev

@pdjdev pdjdev commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Problem

When a "Save changes?" dialog is closed without clicking any button, the result was incorrectly treated as No, causing unsaved changes to be silently discarded. SE4 handled this correctly by treating it as a cancellation.

Cause & Fix

MessageBox.Show returns MessageBoxResult.None when no button is clicked. The affected code paths only checked for MessageBoxResult.Cancel, so None fell through to the "No" branch.

The fix adds || dr == MessageBoxResult.None to all five save-changes guard conditions in MainViewModel.cs:

  • FileCloseTranslation
  • HasChangesContinue
  • ContinueNewOrExitOriginal
  • OnClosing
  • OnWindowClosing

Testing

Tested on Windows 11 x64 (local build).

pdjdev and others added 2 commits June 29, 2026 18:48
Treat anything that is not Yes or No (Cancel, the None returned when the
dialog is dismissed via the title bar, or any future result) as cancel, so
unsaved changes are never silently discarded. Equivalent to the previous
'Cancel || None' check but robust to other non-answers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@niksedk niksedk merged commit 8b5fe90 into SubtitleEdit:main Jun 29, 2026
1 check passed
pull Bot pushed a commit to matrixer2306/subtitleedit that referenced this pull request Jun 29, 2026
The five 'Save changes?' Yes/No/Cancel prompts in MainViewModel each repeated
the same show-dialog-and-decide block. Extract a PromptSaveChanges helper (plus
SaveCurrentSubtitle / SaveCurrentSubtitleOriginal) so the dialog and the
cancel/dismiss handling live in one place. Behavior is unchanged: Yes saves and
proceeds only if the save succeeds, No discards and proceeds, Cancel or a
title-bar dismissal (MessageBoxResult.None) aborts.

Net -36 lines. Follow-up to SubtitleEdit#11985.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants