Skip to content

Keep app open when "Save as" is cancelled on close#12202

Merged
niksedk merged 1 commit into
mainfrom
fix/cancel-save-as-keeps-open
Jul 5, 2026
Merged

Keep app open when "Save as" is cancelled on close#12202
niksedk merged 1 commit into
mainfrom
fix/cancel-save-as-keeps-open

Conversation

@niksedk

@niksedk niksedk commented Jul 5, 2026

Copy link
Copy Markdown
Member

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.OnClosing passed this to PromptSaveChanges:

async () => { await SaveSubtitle(); return true; }

It awaited the save but discarded SaveSubtitle()'s return value and always returned true. SaveSubtitle()SaveSubtitleAs() correctly returns false when the file picker is cancelled, but that false never reached PromptSaveChanges, so the close proceeded as if the save had succeeded.

Fix

Propagate the real result: () => SaveSubtitle(). Now a cancelled "Save as" returns falsePromptSaveChanges returns falseOnClosing returns with e.Cancel still set, so the window stays open.

Fixed the identical lambda in the dead OnWindowClosing handler too (never subscribed, but fixed for consistency so it can't become a future trap). The other three PromptSaveChanges call sites already passed SaveCurrentSubtitle, which returns false on cancel, so they were already correct.

Testing

Verified manually in a local Debug build:

  • Unsaved changes → close → Yes → cancel "Save as" → app stays open
  • Yes → save successfully → app closes ✅
  • No → closes without saving ✅
  • Cancel at the first prompt → stays open ✅

🤖 Generated with Claude Code

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>
@niksedk niksedk merged commit d5bb85b into main Jul 5, 2026
1 of 3 checks passed
@niksedk niksedk deleted the fix/cancel-save-as-keeps-open branch July 5, 2026 06:53
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.

1 participant