jdlorimer / incremental-reading

Anki add-on providing incremental reading features
https://ankiweb.net/shared/info/935264945
ISC License
216 stars 38 forks source link

Exception after updating to newest version of IR #34

Closed levodopa closed 6 years ago

levodopa commented 6 years ago

Anki 2.1.0beta20 Python 3.6.1 Qt 5.9.2 PyQt 5.9 Platform: Windows 10 Flags: frz=True ao=True

Caught exception: File "aqt\progress.py", line 65, in handler File "aqt\clayout.py", line 303, in _renderPreview File "anki\hooks.py", line 34, in runFilter File "O:\OneDrive\AnkiData 2.1\addons21\1081195335\view.py", line 33, in prepareCard self.setZoom() File "O:\OneDrive\AnkiData 2.1\addons21\1081195335\view.py", line 57, in setZoom self.settings['zoom'][str(mw.reviewer.card.id)]) <class 'AttributeError'>: 'NoneType' object has no attribute 'id'

I got this exception after adding additional fields to a empty and by the addon new generated IR3 model. The fields "Title", "Text" and "Source" have not been changed. The error occurs, when I now try to preview a card or to edit the template I added fields for images, overlays and image-caption as i have been used to it in former versions of IR3.

image

levodopa commented 6 years ago

I checked the issue.. last working version with my old card setup was version = '4.3.2'

jdlorimer commented 6 years ago

Thanks for the report. I should have this fixed in a few days.

jdlorimer commented 6 years ago

This should be fixed. Let me know.

levodopa commented 6 years ago

Thanks for fixing the issue. Tried the newest version today. On the first look it seems to work! What was the issue?

jdlorimer commented 6 years ago

There's a fair bit of code that runs when displaying an incremental reading card (to restore the zoom and scroll, to add all the necessary JavaScript for highlighting, extraction, etc.)

I don't often preview my cards, so I hadn't realised that all that set-up code was being run during previews. The reason you were getting an error is because the add-on was trying to get the current card from Anki's reviewer - but when you aren't reviewing, the reviewer doesn't hold a current card.

Since those features are only really useful during reviews, I've restricted them to that context. The code doesn't run at all now during previews.