Fix fatal error when double clicking Add button (#4377)

Prevent adding a note that has already been added by checking if
note.id is set before attempting to add it. This fixes a race
condition when the Add button is clicked multiple times quickly.

Fixes #4376
This commit is contained in:
Arold0 2025-10-05 14:58:16 +02:00 committed by GitHub
parent 1f9d943c8d
commit d11b74fd38
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -249,6 +249,7 @@ Toby Penner <tobypenner01@gmail.com>
Danilo Spillebeen <spillebeendanilo@gmail.com> Danilo Spillebeen <spillebeendanilo@gmail.com>
Matbe766 <matildabergstrom01@gmail.com> Matbe766 <matildabergstrom01@gmail.com>
Amanda Sternberg <mandis.sternberg@gmail.com> Amanda Sternberg <mandis.sternberg@gmail.com>
arold0 <arold0@icloud.com>
******************** ********************

View file

@ -289,6 +289,10 @@ class AddCards(QMainWindow):
def _add_current_note(self) -> None: def _add_current_note(self) -> None:
note = self.editor.note note = self.editor.note
# Prevent adding a note that has already been added (e.g., from double-clicking)
if note.id != 0:
return
if not self._note_can_be_added(note): if not self._note_can_be_added(note):
return return