From bf1af49690151061ba60347ab0ee6a736a466dce Mon Sep 17 00:00:00 2001 From: arold0 Date: Fri, 3 Oct 2025 23:07:13 +0200 Subject: [PATCH] Fix fatal error when double clicking Add button 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