MorphMan
MorphMan copied to clipboard
Learn Now (Ctrl+Shift+N) crashes Anki
Hitting the Ctrl-Shift-N or selecting Learn Now from the Browser's Edit menu consistently crashes Anki Version 2.1.15 (442df9d6). I've been able to consistently replicate the issue on two different Ubuntu 18.04 machines.
Is there a stack trace somewhere I can look at?
This is still an issue, I've had it on more than one OS. Currently Ubuntu 20.04, Anki 2.1.22, Python 3.8.1, Qt 5.14.1, PyQt 5.14.1
Running on CLI displays the following:
malloc_consolidate(): invalid chunk size
fish: “anki” terminated by signal SIGABRT (Abort)
Running with MALLOC_CHECK_=1
:
b'2020-05-24 19:34:37.046795: '
fish: “env MALLOC_CHECK_=1 anki” terminated by signal SIGSEGV (Address boundary error)
This happens on git master and the current version from Anki Addons.
After some testing this works, but it doesn't close the browser window:
diff --git a/morph/browser/learnNow.py b/morph/browser/learnNow.py
index 9ef9127..46473bb 100644
--- a/morph/browser/learnNow.py
+++ b/morph/browser/learnNow.py
@@ -18,8 +18,8 @@ def per(st, c):
def post(st):
for c in st['cards']:
mw.reviewer.cardQueue.append(c)
- st['browser'].close()
- infoMsg("") # Prevents an AttributeError directly above
+ # st['browser'].close()
+ # infoMsg("") # Prevents an AttributeError directly above
tooltip(_('Immediately reviewing {} cards'.format(len(st['cards']))))
return st
Removing infoMsg
will prevent crashing, but still gives an error:
Caught exception:
Traceback (most recent call last):
File "aqt/progress.py", line 76, in handler
File "aqt/browser.py", line 855, in <lambda>
File "</usr/local/share/anki/bin/decorator.pyc:decorator-gen-2>", line 2, in _onRowChanged
File "anki/hooks.py", line 666, in decorator_wrapper
File "anki/hooks.py", line 657, in repl
File "aqt/browser.py", line 858, in _onRowChanged
File "aqt/browser.py", line 807, in updateTitle
RuntimeError: wrapped C/C++ object of type QTableView has been deleted
I don't know enough Anki, Python, or Qt to make a real solution, but hopefully this helps someone. :)
I looked into this issue. I think the RuntimeError at least is caused by pending window events being send to a closed window after the learn now handler returns. Using the timer to delay the window closing fixes the issue for me.
--- learnNow.py.orig 2020-06-18 16:34:04.672600589 -0400
+++ learnNow.py 2020-06-18 16:37:03.394554534 -0400
@@ -18,8 +18,10 @@
def post(st):
for c in st['cards']:
mw.reviewer.cardQueue.append(c)
- st['browser'].close()
- infoMsg("") # Prevents an AttributeError directly above
+
+ browser = st['browser']
+ mw.progress.timer(100, lambda: browser.close(), False) # Delay closing the window.
+
tooltip(_('Immediately reviewing {} cards'.format(len(st['cards']))))
return st