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: anki-2.0.26-1.fc20 Additional info: reporter: libreport-2.2.2 cmdline: python /usr/bin/anki executable: /usr/bin/anki kernel: 3.15.5-200.fc20.x86_64 runlevel: N 5 type: Python uid: 1001 Truncated backtrace: collection.py:178:modSchema:AnkiError: abortSchemaMod Traceback (most recent call last): File "/usr/share/anki/aqt/clayout.py", line 309, in onAddCard self.mm.addTemplate(self.model, t) File "/usr/share/anki/anki/models.py", line 350, in addTemplate self.col.modSchema() File "/usr/share/anki/anki/collection.py", line 178, in modSchema raise AnkiError("abortSchemaMod") AnkiError: abortSchemaMod Local variables in innermost frame: self: <anki.collection._Collection object at 0x7f6d34084050> check: True
Created attachment 919774 [details] File: backtrace
Created attachment 919775 [details] File: environ
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(): return True # if from the full sync menu, ignore if self.hideSchemaMsg: return True return askUser(_("""\ 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): raise AnkiError("abortSchemaMod") self.scm = intTime(1000) self.setMod() but models.py:ModelManager:addTemplate() doesn't catch it: def addTemplate(self, m, template): "Note: should col.genCards() afterwards." if m['id']: self.col.modSchema() <---------- here m['tmpls'].append(template) self._updateTemplOrds(m) self.save(m) 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] untested patch 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: https://anki.tenderapp.com/ 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: Start anki Select language (e.g. English) Confirm language(!) Click the 'sync' button and enter your AnkiWeb ID and password Wait for it to synchronise Find and download any shared deck Click Add Click Cards... Click '+' (top right corner) Answer 'No' to the dialog