FooSoft / anki-connect

Anki plugin to expose a remote API for creating flash cards.
https://foosoft.net/projects/anki-connect/
Other
1.92k stars 218 forks source link

Bug: guiEditNote returns error ('Edit' object has no attribute 'finished') #414

Open Xydez opened 8 months ago

Xydez commented 8 months ago

Opening the editor for a note does not work.

$ curl "localhost:8765" -X POST -d "{\"action\": \"guiEditNote\", \"version\": 6, \"params\": { \"note\": 1703190736523 } }"
{"result": null, "error": "'Edit' object has no attribute 'finished'"}

Any clue what this is and how to fix it?

Thank you so much for this project!

Platform: Windows Anki version: 23.10.1 (Python 3.9.15 Qt 6.6.0 PyQt 6.6.0) AnkiConnect version: 2023-10-29

krischimk commented 8 months ago

Having the same problem... https://github.com/themoeway/yomitan/issues/417

ThisIsntTheWay commented 8 months ago

Yeah, this looks like some issue with 23.10.1 of Anki.
Here is a traceback of the error:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Roaming\Anki2\addons21\2055492159\edit.py", line 479, in open_dialog_and_show_note_with_id
    return aqt.dialogs.open(cls.dialog_registry_tag, note)
  File "aqt", line 136, in open
  File "C:\Users\user\AppData\Roaming\Anki2\addons21\2055492159\edit.py", line 211, in __init__
    aqt.mw.garbage_collect_on_dialog_finish(self)
  File "aqt.main", line 1749, in garbage_collect_on_dialog_finish
AttributeError: 'Edit' object has no attribute 'finished'

Just for fun, I've added finished = True to the plugins Edit class. While the traceback remains identical, the error message is now this:

AttributeError: 'bool' object has no attribute 'connect'

I've never developed plugins for Anki or used Qt in general, so I'm not sure how to proceed.

yibe commented 8 months ago

This was probably caused by https://github.com/ankitects/anki/commit/115f2a425e0c572e0e45f53186cefe9cf9f80842.

As aqt.editcurrent.EditCurrent no longer inherits from QDialog, the Edit class needs some changes to work with 23.10.

https://github.com/FooSoft/anki-connect/blob/1f7fc80b7e7f5ab904ba0e18fa657137d26936e8/plugin/edit.py#L181-L191