mirror of
https://github.com/ankitects/anki.git
synced 2025-11-11 07:07:13 -05:00
Avoid calling checkValid on an empty note
Fix error message when editFocusLost is called after editor destruction https://anki.tenderapp.com/discussions/ankidesktop/11175-bug-in-browser-revealed-by-add-on?unresolve=true To reproduce: 1. Install the attached add-on. (All it does is register a function on the editFocusLost hook, and set the flag to 1 to signify that a field has been updated). 2. Run Anki. Enter the Browse window. Press Enter to display your deck. 3. Select one card. 4. Click inside one of the fields for that card. Now, when you leave that field, the editFocusLost hook will be called. 5. Now, select 2 notes from the browser, with your mouse, without clicking anywhere else before. You will observe this error message: Traceback (most recent call last): File "aqt/progress.pyc", line 69, in handler File "aqt/editor.pyc", line 467, in onUpdate File "aqt/editor.pyc", line 572, in checkValid AttributeError: 'NoneType' object has no attribute 'fields'
This commit is contained in:
parent
b1ecdba42f
commit
3d81ef2c68
1 changed files with 2 additions and 0 deletions
|
|
@ -462,6 +462,8 @@ class Editor(object):
|
|||
"editFocusLost", False, self.note, self.currentField):
|
||||
# something updated the note; schedule reload
|
||||
def onUpdate():
|
||||
if not self.note:
|
||||
return
|
||||
self.stealFocus = True
|
||||
self.loadNote()
|
||||
self.checkValid()
|
||||
|
|
|
|||
Loading…
Reference in a new issue