Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

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

Open
Xydez opened this issue Dec 21, 2023 · 3 comments
Open

Comments

@Xydez
Copy link

Xydez commented Dec 21, 2023

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

@Xydez Xydez changed the title Bug: guiEditNote errors Bug: guiEditNote returns error ('Edit' object has no attribute 'finished') Dec 21, 2023
@krischimk
Copy link

Having the same problem... themoeway/yomitan#417

@ThisIsntTheWay
Copy link

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
Copy link

yibe commented Dec 22, 2023

This was probably caused by ankitects/anki@115f2a4.

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

anki-connect/plugin/edit.py

Lines 181 to 191 in 1f7fc80

class Edit(aqt.editcurrent.EditCurrent):
dialog_geometry_tag = DOMAIN_PREFIX + "edit"
dialog_registry_tag = DOMAIN_PREFIX + "Edit"
dialog_search_tag = DOMAIN_PREFIX + "edit.history"
# depending on whether the dialog already exists,
# upon a request to open the dialog via `aqt.dialogs.open()`,
# the manager will call either the constructor or the `reopen` method
def __init__(self, note):
QDialog.__init__(self, None, Qt.WindowType.Window)
aqt.mw.garbage_collect_on_dialog_finish(self)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants