summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2023-07-23 15:59:56 +0200
committerFlorian Bruhin <me@the-compiler.org>2023-07-23 16:03:03 +0200
commitf8685230a5d55d4755427e3fcc8cab0eb57cd37c (patch)
tree429abadb77148a929d44c4ea045533e1723a061d
parent5e5da1c45857c7d939539105649f695f8fb7f0f5 (diff)
downloadqutebrowser-f8685230a5d55d4755427e3fcc8cab0eb57cd37c.tar.gz
qutebrowser-f8685230a5d55d4755427e3fcc8cab0eb57cd37c.zip
Make sure ipc.shutdown() can be called twice
We still want to make sure that IPC is shut down early when using :restart. However, doing it again should be a nop when quitting qutebrowser then shuts it down again. This accidentally worked before 6373959 ("Always delay stage 2 shutdown, not only with prompts"), because most operations in shutdown() just happened to be idempotent. Because we never returned to the Qt mainloop between the first and the second call, the self._server.deleteLater() call didn't actually delete anything yet. After that change, however, we do end up in shutdown() again with an actually deleted C++ QLocalServer object, so trying to call .close() on it again failed with a RuntimeError. Fixed #7681
-rw-r--r--qutebrowser/misc/ipc.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py
index 9b7e30609..15b158491 100644
--- a/qutebrowser/misc/ipc.py
+++ b/qutebrowser/misc/ipc.py
@@ -427,11 +427,19 @@ class IPCServer(QObject):
@pyqtSlot()
def shutdown(self):
"""Shut down the IPC server cleanly."""
+ if self._server is None:
+ # We can get called twice when using :restart -- there, IPC is shut down
+ # early to avoid processing new connections while shutting down, and then
+ # we get called again when the application is about to quit.
+ return
+
log.ipc.debug("Shutting down IPC (socket 0x{:x})".format(
id(self._socket)))
+
if self._socket is not None:
self._socket.deleteLater()
self._socket = None
+
self._timer.stop()
if self._atime_timer is not None: # pragma: no branch
self._atime_timer.stop()
@@ -439,9 +447,11 @@ class IPCServer(QObject):
self._atime_timer.timeout.disconnect(self.update_atime)
except TypeError:
pass
+
self._server.close()
self._server.deleteLater()
self._remove_server()
+ self._server = None
def send_to_running_instance(socketname, command, target_arg, *, socket=None):