Closed HQYang1979 closed 8 months ago
That is extremely weird....
This line: https://github.com/mortii/anki-morphs/blob/e2dac04e552278dc99018bc82bb81b181ec1acea/ankimorphs/reviewing_utils.py#L234 right above should make sure this never happens....
Were you in the 'reviewing' screen when this happened? Did you do anything out of the ordinary?
yes I was.in the review screen, and just K-ing my way through
yes I was.in the review screen, and just K-ing my way through
Interesting... What happened after the error occurred? Did things work normally afterwards?
I also got an error today that might be semi-related:
Caught exception:
Traceback (most recent call last):
File "aqt.taskman", line 138, in _on_closures_pending
File "aqt.taskman", line 82, in <lambda>
File "aqt.taskman", line 102, in wrapped_done
File "aqt.operations", line 260, in wrapped_done
File "/home/neo/.local/share/Anki2/addons21/472573498/reviewing_utils.py", line 185, in _show_card
self._showQuestion()
File "aqt.reviewer", line 337, in _showQuestion
AttributeError: 'NoneType' object has no attribute 'question'
This happened after I used 'Learn Card Now' in the browser. The commonality between the errors is that they both happen when an object should not be None, so I'm guessing that the objects have been garbage collected somehow...
@mortii it probably has to do with this.
something in the reviewier triggers .cleanup()
here you don't have
if self.card is not None
because self._showQuestion() assumes that self.card is not None
~~also here you don't have in scope above self.card.type, self.card is not None
~~ here you checked for none. Makes me wonder what is the issue with hq
@Vilhelm-Ian Very thorough, nicely done! I'm wondering if we can just gracefully catch the error and ignore it. When I got my error earlier today it didn't actually cause a problem other than the error pop-up window show up, I still saw the card in the review window like I wanted to...
@Vilhelm-Ian Very thorough, nicely done! I'm wondering if we can just gracefully catch the error and ignore it. When I got my error earlier today it didn't actually cause a problem other than the error pop-up window show up, I still saw the card in the review window like I wanted to...
Yes, that's exactly what happened.
@mortii for the self._showquestion() is just to put assert self.card is not None. That's easy. For what happened to hqyang I have no idea how it happened since there is assert just five lines above it. We can just do if self.card is not none and self.card.type != CARD_TYPE . But i have no idea if it would work since it already escaped an assert
I decided to use 'mw.reviwer' directly instead of passing reviewer object to functions since it can get destroyed somewhere in between.
Thanks for the help!
@mortii I think the issue atleast with the self._showquestion is not that the reviewer is destroyed it's that the reviewer calls the function .cleanup which makes the card property be None. And when we manually call the self._showQuestion method the method assumes that card is not none they don't bother checking. Since _showQuestion is a private method they assume we wouldn't be using it. I think even you do use mw.reviewer you will still have to assert mw.reviewer.card
@mortii I think the issue atleast with the self._showquestion is not that the reviewer is destroyed it's that the reviewer calls the function .cleanup which makes the card property be None. And when we manually call the self._showQuestion method the method assumes that card is not none they don't bother checking. Since _showQuestion is a private method they assume we wouldn't be using it. I think even you do use mw.reviewer you will still have to assert mw.reviewer.card
Hmmm, possibly. My fix was just the lowest hanging fruit I could think of. If this error occurs again then we can dig deeper into this :+1:
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Error An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed. If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem. When you've discovered the add-on that is causing the problem, please report the issue to the add-on author. Debug info: Anki 23.10 (51a10f09) Python 3.9.15 Qt 6.5.3 PyQt 6.5.3 Platform: Windows-10-10.0.23595 Flags: frz=True ao=True sv=3 Add-ons, last update check: 2023-12-06 21:29:45 Add-ons possibly involved: ankimorphs-alpha
Caught exception: Traceback (most recent call last): File "C:\Users\Administrator\AppData\Roaming\Anki2\addons21\472573498\reviewing_utils.py", line 298, in
(key_skip.toString(), lambda: _set_card_as_known_and_skip(self, am_config)),
File "C:\Users\Administrator\AppData\Roaming\Anki2\addons21\472573498\reviewing_utils.py", line 244, in _set_card_as_known_and_skip
if self.card.type != CARD_TYPE_NEW:
AttributeError: 'NoneType' object has no attribute 'type'