From f2fbf667cd2eb7c9b3c00c68ba86610bdccdceb3 Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Sun, 26 Apr 2020 16:53:23 +0200 Subject: [PATCH] onModelChange: replacing try by if --- qt/aqt/addcards.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/qt/aqt/addcards.py b/qt/aqt/addcards.py index 513f4b199..4928beb18 100644 --- a/qt/aqt/addcards.py +++ b/qt/aqt/addcards.py @@ -103,14 +103,11 @@ class AddCards(QDialog): # copy identical fields if fieldName in oldFields: note[fieldName] = oldNote[fieldName] - else: + elif n < len(oldNote.model()["flds"]): # set non-identical fields by field index - try: - oldFieldName = oldNote.model()["flds"][n]["name"] - if oldFieldName not in newFields: - note.fields[n] = oldNote.fields[n] - except IndexError: - pass + oldFieldName = oldNote.model()["flds"][n]["name"] + if oldFieldName not in newFields: + note.fields[n] = oldNote.fields[n] self.removeTempNote(oldNote) self.editor.note = note # When on model change is called, reset is necessarily called.