From d11b74fd38835f69adab31573b50fc305337615d Mon Sep 17 00:00:00 2001 From: Arold0 <165577303+arold0@users.noreply.github.com> Date: Sun, 5 Oct 2025 14:58:16 +0200 Subject: [PATCH] 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 --- CONTRIBUTORS | 1 + qt/aqt/addcards.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7d44671ca..a18833b04 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -249,6 +249,7 @@ Toby Penner Danilo Spillebeen Matbe766 Amanda Sternberg +arold0 ******************** diff --git a/qt/aqt/addcards.py b/qt/aqt/addcards.py index a27d86234..01d7423d8 100644 --- a/qt/aqt/addcards.py +++ b/qt/aqt/addcards.py @@ -289,6 +289,10 @@ class AddCards(QMainWindow): def _add_current_note(self) -> None: 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): return