Correct way of refreshing note editor after updating note (HyperTTS hard crash report)

Some users are experiencing issues with a hard crash on HyperTTS when adding audio from the editor buttons. I’m able to reproduce and it crashes when calling editor.set_note, right here: anki-hyper-tts/hypertts.py at main · Language-Tools/anki-hyper-tts · GitHub
the note gets updated right here: anki-hyper-tts/hypertts.py at main · Language-Tools/anki-hyper-tts · GitHub

This results in anki just crashing on windows with no logging, stack trace whatsoever.

Does the call to editor.set_note seem wrong in this situation ? If so, what’s the right way of getting the editor to refresh after I updated a field from python ? I suspect I’m experiencing a crash at the Qt level but not sure how to get more debug details about it.

What happens if you invoke that routine not directly in the bridge handler, but in a timeout triggered by the bridge handler?

Looks like your intuition was spot on. Here’s the situation:

  • I actually instantiate a PyQt dialog from the bridge handler if the user selects “new preset” (as opposed to an existing present where sound will be added directly)
  • The user configures the audio setting, then clicks “add to note”
  • then the editor.set_note is now called on the same thread as the bridge handler I believe.
  • if I call editor.set_note as a aqt.mw.taskman.run_on_main task, no crash.

So I think that’s the fix I need, many thanks !

I’m experiencing this issue right now and can’t find any information about it except this post, which I understand like ten percent of. I get a hard crash every time I try to apply a preset to one or several cards, regardless if I press Add audio, Run all or Apply to note.