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

database use after close #67

Open
kieranlblack opened this issue Feb 25, 2024 · 1 comment
Open

database use after close #67

kieranlblack opened this issue Feb 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@kieranlblack
Copy link
Contributor

Describe the bug
Closed database checks still not right. I'm still getting a use after close error:

Traceback (most recent call last):
  File "C:\Users\kiera\git\anki\qt\aqt\webview.py", line 50, in cmd
    return json.dumps(self.onCmd(str))
  File "C:\Users\kiera\git\anki\qt\aqt\webview.py", line 157, in _onCmd
    return self._onBridgeCmd(str)
  File "C:\Users\kiera\git\anki\qt\aqt\webview.py", line 686, in _onBridgeCmd
    return self.onBridgeCmd(cmd)
  File "C:\Users\kiera\git\anki\qt\aqt\editor.py", line 425, in onBridgeCmd
    if gui_hooks.editor_did_unfocus_field(False, self.note, ord):
  File "C:\Users\kiera\git\anki\out/qt\_aqt\hooks.py", line 2548, in __call__
    changed = anki.hooks.runFilter(
  File "C:\Users\kiera\git\anki\pylib\anki\hooks.py", line 45, in runFilter
    arg = func(arg, *args)
  File "C:\Users\kiera\coding\anki-chinese-support-3\addons21\anki-chinese-support-3\chinese\edit.py", line 122, in onFocusLost
    if not update_fields(note, field, allFields):
  File "C:\Users\kiera\coding\anki-chinese-support-3\addons21\anki-chinese-support-3\chinese\behavior.py", line 346, in update_fields
    fill_alt(hanzi, copy)
  File "C:\Users\kiera\coding\anki-chinese-support-3\addons21\anki-chinese-support-3\chinese\behavior.py", line 99, in fill_alt
    alts = dictionary.get_variants(hanzi)
  File "C:\Users\kiera\coding\anki-chinese-support-3\addons21\anki-chinese-support-3\chinese\database.py", line 246, in get_variants
    self.c.execute(
sqlite3.ProgrammingError: Cannot operate on a closed database.

To Reproduce

  1. open add new card window
  2. fill in hanzi field
  3. click close on main window
  4. trigger fill with any sort of event on the add window
  5. see error above

Probably because the handler for closing is being called even though the add window is still open. Might be an Anki issue tbh but we can at least account for it.

@Gustaf-C
Copy link
Owner

Yeah it seems like the profile_will_close hooks is triggered when the main window is closed, which leads to issues when other windows are open. I don't think that is intended behaviour.

@Gustaf-C Gustaf-C added the bug Something isn't working label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants