Shut down correctly while being asked a question.
This commit is contained in:
parent
9a6bff315b
commit
3307c5f518
2
doc/BUGS
2
doc/BUGS
@ -9,8 +9,6 @@ Downloads
|
|||||||
- Download focus rectangle on windows
|
- Download focus rectangle on windows
|
||||||
- download-page on qute:htmllog is broken
|
- download-page on qute:htmllog is broken
|
||||||
- Prevent invalid filenames (e.g. com1) when downloading on Windows
|
- Prevent invalid filenames (e.g. com1) when downloading on Windows
|
||||||
- When quitting while being asked for a download filename: segfault / memory
|
|
||||||
corruption
|
|
||||||
|
|
||||||
Webview
|
Webview
|
||||||
-------
|
-------
|
||||||
|
@ -704,6 +704,23 @@ class Application(QApplication):
|
|||||||
return
|
return
|
||||||
self._shutting_down = True
|
self._shutting_down = True
|
||||||
log.destroy.debug("Shutting down with status {}...".format(status))
|
log.destroy.debug("Shutting down with status {}...".format(status))
|
||||||
|
if self.mainwindow.status.prompt.prompter.shutdown():
|
||||||
|
# If shutdown was called while we were asking a question, we're in
|
||||||
|
# a still sub-eventloop (which gets quitted 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, partial(self._shutdown, status))
|
||||||
|
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(status)
|
||||||
|
|
||||||
|
def _shutdown(self, status):
|
||||||
|
"""Second stage of shutdown."""
|
||||||
|
log.destroy.debug("Stage 2 of shutting down...")
|
||||||
# Remove eventfilter
|
# Remove eventfilter
|
||||||
if self.modeman is not None:
|
if self.modeman is not None:
|
||||||
log.destroy.debug("Removing eventfilter...")
|
log.destroy.debug("Removing eventfilter...")
|
||||||
|
@ -157,6 +157,23 @@ class Prompter:
|
|||||||
self._busy = True
|
self._busy = True
|
||||||
return mode
|
return mode
|
||||||
|
|
||||||
|
def shutdown(self):
|
||||||
|
"""Cancel all blocking questions.
|
||||||
|
|
||||||
|
Quits and removes all running eventloops.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
True if loops needed to be aborted,
|
||||||
|
False otherwise.
|
||||||
|
"""
|
||||||
|
if self._loops:
|
||||||
|
for loop in self._loops:
|
||||||
|
loop.quit()
|
||||||
|
loop.deleteLater()
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
@pyqtSlot(KeyMode)
|
@pyqtSlot(KeyMode)
|
||||||
def on_mode_left(self, mode):
|
def on_mode_left(self, mode):
|
||||||
"""Clear and reset input when the mode was left."""
|
"""Clear and reset input when the mode was left."""
|
||||||
|
Loading…
Reference in New Issue
Block a user