From 246cff63edba30f3fd4d5d2dcaa17dc98aee459d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 1 Aug 2014 23:26:33 +0200 Subject: [PATCH] Use singleShot timer to call QApplication.exit. --- qutebrowser/app.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 1590c9488..bd370eb38 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -27,6 +27,7 @@ import configparser import signal from bdb import BdbQuit from base64 import b64encode +from functools import partial from PyQt5.QtWidgets import QApplication, QDialog, QMessageBox from PyQt5.QtCore import (pyqtSlot, QTimer, QEventLoop, Qt, QStandardPaths, @@ -716,7 +717,13 @@ class Application(QApplication): qInstallMessageHandler(None) # Now we can hopefully quit without segfaults log.destroy.debug("Calling QApplication::exit...") + # We use a singleshot timer to exit here to minimize the likelyhood of + # segfaults. + QTimer.singleShot(0, partial(self.exit, status)) + + def exit(self, status): + """Override exit to trace late shutdown if requested.""" if self.args.debug: log.destroy.debug("Now logging late shutdown.") trace_lines(True) - self.exit(status) + super().exit(status)