Description of problem:
Answered 'No' to a dialog that appeared when clicking the '+' button in the Card Types dialog.
Version-Release number of selected component:
cmdline: python /usr/bin/anki
runlevel: N 5
Traceback (most recent call last):
File "/usr/share/anki/aqt/clayout.py", line 309, in onAddCard
File "/usr/share/anki/anki/models.py", line 350, in addTemplate
File "/usr/share/anki/anki/collection.py", line 178, in modSchema
Local variables in innermost frame:
self: <anki.collection._Collection object at 0x7f6d34084050>
Created attachment 919774 [details]
Created attachment 919775 [details]
I've tried it for my decks, but so far it doesn't happen for me.
If you can reproduce the issue, please can you provide some detailed step-by-step instructions? Thanks!
It's from aqt/main.py:AnkiQt:onSchemaMod():
def onSchemaMod(self, arg):
# if triggered in sync, make sure we don't use the gui
if not self.inMainThread():
# if from the full sync menu, ignore
The requested change will require a full upload of the database when \
you next synchronize your collection. If you have reviews or other changes \
waiting on another device that haven't been synchronized here yet, they \
will be lost. Continue?"""))
Answering 'no' to this dialog results in the caller (collection.py:_Collection:modSchema()) raising an exception:
def modSchema(self, check=True):
"Mark schema modified. Call this first so user can abort if necessary."
if not self.schemaChanged():
if check and not runFilter("modSchema", True):
self.scm = intTime(1000)
but models.py:ModelManager:addTemplate() doesn't catch it:
def addTemplate(self, m, template):
"Note: should col.genCards() afterwards."
self.col.modSchema() <---------- here
In fact, this is the only place in the code that uses AnkiError at all.
At some level, there needs to be a try:...except AnkiError: wrapped around this call. Judging from where DeckRenameError is caught, it should probably be at the aqt level.
Created attachment 922854 [details]
Here's a patch that does that (against current git master). I don't know enough about Anki internals to know if it makes sense.
I have asked the upstream developer about his opinion, but there was some reluctance to take that patch.
Unfortunately, I can't reproduce the problem and I'm not familiar enough with the code to judge the correctness of the patch (sure, it looks reasonable).
I'm afraid I don't have a better solution besides asking you to report the problem directly to upstream:
I'm closing this bug report as "UPSTREAM" for now.
If you can provide step-by-step instructions how to reproduce the issue (based on an empty deck), then I would be happy to test and apply the patch and to report the concrete issue upstream by myself. In that case, please attach the information and re-open the bug.
Thanks for you understanding.
Here's how to reproduce it:
Select language (e.g. English)
Click the 'sync' button and enter your AnkiWeb ID and password
Wait for it to synchronise
Find and download any shared deck
Click '+' (top right corner)
Answer 'No' to the dialog