Fix bug(s) caused by deleting a notetype currently selected in AddCards (#1514)
* Remove unneeded old.note_type() call Fixes TypeError thrown after deleting a notetype that's currently selected in the editor. * Handle IndexError on notetype change Occurs in the Add window when changing the notetype via NotetypeChooser from - the notetype that's auto-selected after deleting the currently selected notetype - to a notetype with fewer fields than the auto-selected one * Add return to exception handler to properly ignore the command.
This commit is contained in:
parent
d0c6f0d7ba
commit
3015ddd2c1
@ -139,10 +139,9 @@ class AddCards(QMainWindow):
|
||||
# copy identical fields
|
||||
if field_name in old_fields:
|
||||
new[field_name] = old[field_name]
|
||||
elif n < len(old.note_type()["flds"]):
|
||||
elif n < len(old_fields):
|
||||
# set non-identical fields by field index
|
||||
old_field_name = old.note_type()["flds"][n]["name"]
|
||||
if old_field_name not in new_fields:
|
||||
if old_fields[n] not in new_fields:
|
||||
new.fields[n] = old.fields[n]
|
||||
new.tags = old.tags
|
||||
|
||||
|
@ -354,7 +354,11 @@ noteEditorPromise.then(noteEditor => noteEditor.toolbar.toolbar.appendGroup({{
|
||||
print("ignored late blur")
|
||||
return
|
||||
|
||||
self.note.fields[ord] = self.mungeHTML(txt)
|
||||
try:
|
||||
self.note.fields[ord] = self.mungeHTML(txt)
|
||||
except IndexError:
|
||||
print("ignored late blur after notetype change")
|
||||
return
|
||||
|
||||
if not self.addMode:
|
||||
self._save_current_note()
|
||||
|
Loading…
Reference in New Issue
Block a user