Go to file
Arthur Milchior 0b633dbf40 Ensuring "setNote" is called only once during changing of note type
Initially, I wanted to solve the bug reported on
https://github.com/Arthur-Milchior/anki-html-src-in-field/issues/1

After some research, I finally discovered that the trouble was that,
when we change the note type in add card, the method
`aqt.editor.Editor.loadNote` is called twice. In itself, it would not
be a problem, but given the way callback works, its call back is
called twice on the last version of the webview. Which means that
`gui_hooks.editor_did_load_note` is called twice, which breaks this
add-on.

The reason why loadNote is called twice is because `setNote` is called
twice in `aqt.modelchooser.onModelChange`. The first time through
`gui_hooks.current_note_type_did_change` which calls
`addcards.AddCards.onModelChange` which calls `loadNote`, the second
time through `self.mw.reset()` which calls
`gui_hooks.state_did_reset()` which calls `addcards.AddCards.onReset`
which calls `setAndFocusNote` which calls `setNote`.

I should note furthermore that currently,
`gui_hooks.current_note_type_did_change` is called only when the model
chooser change a model. And `addCards.onModelChange` is never called,
only added to the hook `gui_hooks.current_note_type_did_change`. So
removing the line of code removed in this commit will have no side
effect in Anki itself. It will only affect the fact that this method
is called twice.

I do not know of any add-on calling `onModelChange` or
`gui_hooks.current_note_type_did_change`, but it means little, so of
course, it may always mean an add-on will break because of this
change. No way of being sure.
2020-03-26 21:26:13 +01:00
.github possible CI fix 2020-03-25 09:45:50 +10:00
meta bump version 2020-03-19 10:46:01 +10:00
proto use backend for v1 and v2 cutoff calculations 2020-03-22 14:28:26 +10:00
pylib don't error when -l passes in language without _ 2020-03-25 08:53:31 +10:00
qt Ensuring "setNote" is called only once during changing of note type 2020-03-26 21:26:13 +01:00
rslib add newline to mear clearly separate different ftl files 2020-03-25 08:53:42 +10:00
rspy Merge remote-tracking branch 'danielelmes/master' into fix_tests_on_windows 2020-03-23 18:44:11 -03:00
.gitattributes ftl git attributes 2020-03-20 20:33:12 +10:00
.gitignore output into dist/ 2020-01-03 14:32:26 +10:00
CONTRIBUTORS Added name to contributors 2020-03-23 13:08:50 -06:00
LICENSE drop pystache and move legacy code into separate file 2020-01-11 19:38:30 +10:00
Makefile Fixed mypy and pylint not building on Windows 2020-03-17 19:48:16 -03:00
pkgkey.asc add public key for release signing 2018-09-18 10:40:45 +10:00
README.contributing mention need to update translations and link to docs 2020-02-26 18:05:32 +10:00
README.development remove svelte/react experiments for now 2020-03-17 20:49:58 +10:00
README.md Created a relative badge link README.md 2020-03-01 23:10:40 -03:00
run Fixed development compilation with Windows 10 2020-02-24 14:59:11 -03:00

This repo contains all the code for the computer version of Anki.

If you'd like to try development builds of Anki but don't feel comfortable building the code, please see https://anki.tenderapp.com/discussions/beta-testing

For more information on building, please see README.development

If you'd like to contribute code, please see README.contributing