Prevent error when double-tapping delete key in browser

on_all_or_selected_rows_changed() unsets the editor note, but it is
called too late - by that time the note has already been deleted, and
the editor sometimes tries to save the deleted note due to an unfocus/
key timeout.

https://forums.ankiweb.net/t/two-suppr-lead-to-an-empty-warning/20860

Will need to check that this does not regression when #1691 is merged.
This commit is contained in:
Damien Elmes 2022-06-20 11:07:38 +10:00
parent e5a74838c9
commit 05adb50153

View file

@ -684,6 +684,7 @@ class Browser(QMainWindow):
if focus != self.form.tableView: if focus != self.form.tableView:
return return
self.editor.set_note(None)
nids = self.table.to_row_of_unselected_note() nids = self.table.to_row_of_unselected_note()
remove_notes(parent=self, note_ids=nids).run_in_background() remove_notes(parent=self, note_ids=nids).run_in_background()