Try to address crashes on shutdown

I was able to reproduce the crashes fairly reliably by opening the
prefs screen on startup and shutting down the app after 600ms; after
this change the crashes no longer seem to occur.
This commit is contained in:
Damien Elmes 2022-12-03 19:33:51 +10:00
parent df38bc627c
commit 509e0a9811

View file

@ -519,7 +519,16 @@ class AnkiQt(QMainWindow):
self.mediaServer.shutdown()
# Rust background jobs are not awaited implicitly
self.backend.await_backup_completion()
self.app.exit(0)
self.deleteLater()
app = self.app
def exit():
# try to ensure Qt objects are deleted in a logical order,
# to prevent crashes on shutdown
gc.collect()
app.exit(0)
self.progress.single_shot(100, exit, False)
# Sound/video
##########################################################################