From e81edc82247e3e9c1aa27955a0f883c3a2c9affb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 4 Mar 2017 17:57:09 +0100 Subject: [PATCH] ipc: Delay deleting of QLocalSocket on disconnect Fixes #2396. See https://bugreports.qt.io/browse/QTBUG-59297 and https://github.com/qutebrowser/qutebrowser/issues/2321#issuecomment-284024213 --- qutebrowser/misc/ipc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py index 2e918ed07..6aefe6356 100644 --- a/qutebrowser/misc/ipc.py +++ b/qutebrowser/misc/ipc.py @@ -27,7 +27,7 @@ import getpass import binascii import hashlib -from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, Qt +from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, Qt, QTimer from PyQt5.QtNetwork import QLocalSocket, QLocalServer, QAbstractSocket import qutebrowser @@ -281,7 +281,11 @@ class IPCServer(QObject): if self._socket is None: log.ipc.debug("In on_disconnected with None socket!") else: - self._socket.deleteLater() + # For some reason Qt can still get delayed canReadNotifications + # internally, so if we call deleteLater() right away and then call + # QApplication::processEvents() somewhere in the code, we can get a + # segfault. + QTimer.singleShot(500, self._socket.deleteLater) self._socket = None # Maybe another connection is waiting. self.handle_connection()