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'
the canFocus/canCopy separate variables was silly, as we ended up
with text that could be copied from the context menu but not with
a shortcut key. also we default to allowing focus now, since that's
the more sensible default. fixes copy issues with card info dialog and
some addons
Fixes bug #950. We need to keep an eye out for media filename problems,
as this line is probably not necessary anymore with changes to the way
Anki handles encoding but could potentially introduce issues.
- use html as the first choice for incoming drops/pastes
- when filtering incoming html, automatically localize any remote image
references
- add a special case for pasting/dropping from google images when html
stripping is on
- move filtering code into editor
when a user copies an image from the browser to the clipboard, we need to do
this so the image pastes, as we currently don't support images derived from
html pastes (issue 92)
contrary to commit 3576475, we do need to quote when adding media on windows
as well, as it seems webkit can not handle all representations variants when
passed unicode
as we're stripping # and % when adding characters, hopefully that's the last
of it!
prior to this change, if you entered an empty field, turned on bold,
typed some text, and then backspaced over the text, it would expand
to two lines and the formatting would not go away
- utf8/unicode is valid in the src string, provided we escape quotes
- and we escape when setting fields in the editor, leading to double escaping
if we do that
- and we strip quotes when adding
this means that copying&pasting images on linux/firefox will redownload the
image which is wasteful, but Windows users make up the majority of the
userbase
- allow creation of cloze deletion when note type not selected; warn with
tooltip. prevents selection from getting lost
- warn before adding cloze note type with no deletions
- treat # specially instead of quoting entire string, as urllib unfortunately
can't handle utf8 quoted text
- make sure we pass utf8 to quote() in _addMedia()