mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
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
2 changed files with 7 additions and 4 deletions
|
@ -139,10 +139,9 @@ class AddCards(QMainWindow):
|
||||||
# copy identical fields
|
# copy identical fields
|
||||||
if field_name in old_fields:
|
if field_name in old_fields:
|
||||||
new[field_name] = old[field_name]
|
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
|
# set non-identical fields by field index
|
||||||
old_field_name = old.note_type()["flds"][n]["name"]
|
if old_fields[n] not in new_fields:
|
||||||
if old_field_name not in new_fields:
|
|
||||||
new.fields[n] = old.fields[n]
|
new.fields[n] = old.fields[n]
|
||||||
new.tags = old.tags
|
new.tags = old.tags
|
||||||
|
|
||||||
|
|
|
@ -354,7 +354,11 @@ noteEditorPromise.then(noteEditor => noteEditor.toolbar.toolbar.appendGroup({{
|
||||||
print("ignored late blur")
|
print("ignored late blur")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
self.note.fields[ord] = self.mungeHTML(txt)
|
self.note.fields[ord] = self.mungeHTML(txt)
|
||||||
|
except IndexError:
|
||||||
|
print("ignored late blur after notetype change")
|
||||||
|
return
|
||||||
|
|
||||||
if not self.addMode:
|
if not self.addMode:
|
||||||
self._save_current_note()
|
self._save_current_note()
|
||||||
|
|
Loading…
Reference in a new issue