fix(app): keep window open when a chosen save does not complete#2361
fix(app): keep window open when a chosen save does not complete#2361wkentaro wants to merge 1 commit into
Conversation
Verdict: A tight, correct fix. Verification:
follow-ups: #2362 (pre-existing: |
_can_continue() returned True unconditionally after the user chose Save in the unsaved-changes prompt, even when _save_label_file() did not actually persist the file (a cancelled Save-As dialog, or a failed write). The caller then discarded the in-memory annotations. Return the real dirty state instead so a save that did not clear the flag aborts the close/switch and keeps the annotations.
e1bb1ae to
dd113a2
Compare
Re-affirming |
When the unsaved-changes prompt appears (on close or file-switch) and the user chooses Save, the app previously proceeded unconditionally — even when the save never actually happened.
_can_continue()returnedTrueright after calling_save_label_file()without checking whether the file was written, so the caller went on to discard the in-memory annotations._save_label_file()only clears the dirty flag (mark_clean()) on a successfulsave_labels(). It silently no-ops when the Save-As dialog is cancelled (empty path) and returns without clearing on a write failure (LabelFileError). In both cases the annotations were lost even though the user asked to save them.The fix returns the real dirty state (
return not self._is_changed), so a save that did not complete aborts the close/switch and keeps the window open with the work intact.Test plan
test_close_choose_save_but_cancel_save_dialog_keeps_window_open— Save chosen, Save-As dialog cancelled: window stays open, still dirty, no file writtentest_close_choose_save_but_write_fails_keeps_window_open— Save chosen,save_labelsfails: window stays open, still dirtyreturn Trueand pass with the fixuv run pytest(809 passed)