summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qutebrowser/mainwindow/prompt.py16
-rw-r--r--qutebrowser/misc/quitter.py27
2 files changed, 16 insertions, 27 deletions
diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py
index 279721b2a..db7553e7e 100644
--- a/qutebrowser/mainwindow/prompt.py
+++ b/qutebrowser/mainwindow/prompt.py
@@ -131,20 +131,12 @@ class PromptQueue(QObject):
"""Cancel all blocking questions.
Quits and removes all running event loops.
-
- Return:
- True if loops needed to be aborted,
- False otherwise.
"""
- log.prompt.debug("Shutting down with loops {}".format(self._loops))
+ log.prompt.debug(f"Shutting down with loops {self._loops}")
self._shutting_down = True
- if self._loops:
- for loop in self._loops:
- loop.quit()
- loop.deleteLater()
- return True
- else:
- return False
+ for loop in self._loops:
+ loop.quit()
+ loop.deleteLater()
@pyqtSlot(usertypes.Question, bool)
def ask_question(self, question, blocking):
diff --git a/qutebrowser/misc/quitter.py b/qutebrowser/misc/quitter.py
index 92764a3a4..a849aec70 100644
--- a/qutebrowser/misc/quitter.py
+++ b/qutebrowser/misc/quitter.py
@@ -221,21 +221,18 @@ class Quitter(QObject):
status, session))
sessions.shutdown(session, last_window=last_window)
-
- if prompt.prompt_queue.shutdown():
- # If shutdown was called while we were asking a question, we're in
- # a still sub-eventloop (which gets quit now) and not in the main
- # one.
- # This means we need to defer the real shutdown to when we're back
- # in the real main event loop, or we'll get a segfault.
- log.destroy.debug("Deferring real shutdown because question was "
- "active.")
- QTimer.singleShot(0, functools.partial(self._shutdown_2, status,
- is_restart=is_restart))
- else:
- # If we have no questions to shut down, we are already in the real
- # event loop, so we can shut down immediately.
- self._shutdown_2(status, is_restart=is_restart)
+ prompt.prompt_queue.shutdown()
+
+ # If shutdown was called while we were asking a question, we're in
+ # a still sub-eventloop (which gets quit now) and not in the main
+ # one.
+ # But there's also other situations where it's problematic to shut down
+ # immediately (e.g. when we're just starting up).
+ # This means we need to defer the real shutdown to when we're back
+ # in the real main event loop, or we'll get a segfault.
+ log.destroy.debug("Deferring shutdown stage 2")
+ QTimer.singleShot(
+ 0, functools.partial(self._shutdown_2, status, is_restart=is_restart))
def _shutdown_2(self, status: int, is_restart: bool) -> None:
"""Second stage of shutdown."""