Keep app open when "Save as" is cancelled on close#12202
Merged
Conversation
Closing with unsaved changes and choosing Yes to save opened the "Save as"
dialog; cancelling it closed the app anyway, losing the work. The close
handler passed `async () => { await SaveSubtitle(); return true; }` to
PromptSaveChanges, discarding SaveSubtitle()'s result and always reporting
success - so a cancelled save picker still counted as saved.
Propagate the real result (() => SaveSubtitle()): a cancelled "Save as" now
returns false, PromptSaveChanges returns false, and OnClosing returns with
e.Cancel still set, so the window stays open. Fixed the identical lambda in the
dead OnWindowClosing handler too. The other PromptSaveChanges call sites already
passed SaveCurrentSubtitle, which returns false on cancel.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Reported by a user: closing a project with unsaved changes, choosing Yes to save, then cancelling the "Save as" dialog closed the app anyway — losing the work. The expected behaviour is to cancel the close (stay open).
Root cause
MainViewModel.OnClosingpassed this toPromptSaveChanges:It awaited the save but discarded
SaveSubtitle()'s return value and always returnedtrue.SaveSubtitle()→SaveSubtitleAs()correctly returnsfalsewhen the file picker is cancelled, but thatfalsenever reachedPromptSaveChanges, so the close proceeded as if the save had succeeded.Fix
Propagate the real result:
() => SaveSubtitle(). Now a cancelled "Save as" returnsfalse→PromptSaveChangesreturnsfalse→OnClosingreturns withe.Cancelstill set, so the window stays open.Fixed the identical lambda in the dead
OnWindowClosinghandler too (never subscribed, but fixed for consistency so it can't become a future trap). The other threePromptSaveChangescall sites already passedSaveCurrentSubtitle, which returnsfalseon cancel, so they were already correct.Testing
Verified manually in a local Debug build:
🤖 Generated with Claude Code