Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue after adding a card #6

Open
yzhang1337 opened this issue Jun 7, 2019 · 7 comments
Open

Issue after adding a card #6

yzhang1337 opened this issue Jun 7, 2019 · 7 comments

Comments

@yzhang1337
Copy link

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 on the add-ons section of our support site.
Debug info:
Anki 2.1.12 (eef86bf3) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Mac 10.14.5
Flags: frz=True ao=True sv=2
Add-ons possibly involved: Auto Markdown, Search in Add Card Dialog, Frozen Fields

Caught exception:
File "aqt/webview.py", line 27, in cmd
File "aqt/webview.py", line 85, in _onCmd
File "aqt/webview.py", line 363, in _onBridgeCmd
File "", line 2, in myOnBridgeCmd
File "anki/hooks.py", line 74, in decorator_wrapper
File "anki/hooks.py", line 71, in repl
File "/Users/yilunzhang/Library/Application Support/Anki2/addons21/516643804/main.py", line 212, in onBridge
return _old(self, str)
File "/Users/yilunzhang/Library/Application Support/Anki2/addons21/1781298089/init.py", line 317, in myOnBridgeCmd
oldOnBridge(self, cmd)
File "aqt/editor.py", line 286, in onBridgeCmd
File "anki/hooks.py", line 29, in runHook
File "/Users/yilunzhang/Library/Application Support/Anki2/addons21/1030875226/editor.py", line 158, in editFocusGainedHook
editor_instance.web.eval("""document.getElementById('f%s').innerHTML = %s;""" % (field_id, json.dumps(md)))
<class 'AttributeError'>: 'NoneType' object has no attribute 'eval'

@TheDemystifier
Copy link

Another similar error in editor.py :

Anki 2.1.13 (3ba55990) Python 3.6.7 Qt 5.12.1 PyQt 5.11.3
Platform: Windows 7
Flags: frz=True ao=True sv=1

Caught exception:
  File "aqt\webview.py", line 27, in cmd
  File "aqt\webview.py", line 87, in _onCmd
  File "aqt\webview.py", line 368, in _onBridgeCmd
  File "aqt\editor.py", line 273, in onBridgeCmd
  File "anki\hooks.py", line 39, in runFilter
  File "C:\Users\PC\AppData\Roaming\Anki2\addons21\1030875226\editor.py", line 177, in editFocusLostFilter
    editor_instance.web.eval(enableFieldEditingJS(field_id))
<class 'AttributeError'>: 'NoneType' object has no attribute 'eval'

@JanSurft
Copy link
Contributor

Do you get these errors from the latest master or from the version mentioned here: https://ankiweb.net/shared/info/1030875226?

@yzhang1337
Copy link
Author

yzhang1337 commented Jun 12, 2019 via email

@gregorrr
Copy link
Owner

This is a bit of a tricky one to solve. The problem arises because the editFocusGained and editFocusLost hooks don't receive a reference to the current Editor instance. The current solution is a bit hacky: we're keeping a reference to the Editor instance that is passed to the setupEditorButtons hook but evidently that doesn't always work!

Even keeping a reference to the EditorWebView itself doesn't prevent it from being deleted:
<class 'RuntimeError'>: wrapped C/C++ object of type EditorWebView has been deleted

I've added a function to respond to the loadNote hook to hopefully keep a reference to the correct Editor instance. That, along with the extra safety checks performed by @JanSurft will hopefully help.

If not, there are some other approaches to consider.

@gregorrr
Copy link
Owner

gregorrr commented Jul 4, 2019

@yzhang1337 @TheDemystifier are you guys having this issue on the latest version of the add-on?

@yzhang1337
Copy link
Author

yzhang1337 commented Jul 4, 2019 via email

@gregorrr
Copy link
Owner

gregorrr commented Jul 5, 2019

Whichever version is the one that could be downloaded from AnkiWeb on June 12th! Thanks, Yilun

Can you try the latest version from AnkiWeb and let me know if it's still a problem? It's from 18th of June.

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

No branches or pull requests

4 participants