dae/ankiqt — pull request #11 by illforyou (2012-04-08 08:52:10+00:00)
Title: My first (potential) contribution to the Anki code. I have limited exper...

...ience programming (C++ mostly) but I had an error with Anki2 so I hunted it down and found a fix. Let me know what you think!

Error 1: Suppose there are N fields. If the N-1 field goes to be deleted, but the Nth field is sortf, then before this patch Anki leaves sortf as the Nth field (an invalid bound) and returns from fields.py to browser.py to yield an error. This change handles the problem gracefully. (Error before fix shown below)
File "C:\Users\root\Dev\anki2b2\ankiqt\aqt\browser.py", line 77, in data
return self.columnData(index)
File "C:\Users\root\Dev\anki2b2\ankiqt\aqt\browser.py", line 206, in columnData
return self.formatQA(f.fields[self.col.models.sortIdx(f.model())])
IndexError: list index out of range

Error 2: Suppose N fields. If the Nth field is being deleted and is also the sortf field, there is an error. This change handles the problem gracefully. (Error below)
File "C:\Users\root\Dev\anki2b2\ankiqt\aqt\fields.py", line 101, in onDelete
self.mm.remField(self.model, f)
File "C:\Users\root\Dev\anki2b2\ankiqt\..\libanki\anki\models.py", line 241, in remField
self.col.updateFieldCache(self.nids(m), csum=False)
TypeError: updateFieldCache() got an unexpected keyword argument 'csum'