Clean up shutdown
This commit is contained in:
parent
04c3a912e8
commit
cc1ea76d9d
2
TODO
2
TODO
@ -20,8 +20,6 @@ Before 0.1
|
|||||||
Style
|
Style
|
||||||
=====
|
=====
|
||||||
|
|
||||||
- somehow clean up init() and save() calls
|
|
||||||
|
|
||||||
New big features
|
New big features
|
||||||
================
|
================
|
||||||
|
|
||||||
|
@ -583,38 +583,26 @@ class QuteBrowser(QApplication):
|
|||||||
For some reason lastWindowClosing sometimes seem to get emitted twice,
|
For some reason lastWindowClosing sometimes seem to get emitted twice,
|
||||||
so we make sure we only run once here.
|
so we make sure we only run once here.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-branches
|
|
||||||
if self._shutting_down:
|
if self._shutting_down:
|
||||||
return
|
return
|
||||||
self._shutting_down = True
|
self._shutting_down = True
|
||||||
log.destroy.debug("Shutting down...")
|
log.destroy.debug("Shutting down...")
|
||||||
# Save config
|
to_save = []
|
||||||
|
# Save everything
|
||||||
if self.config.get('general', 'auto-save-config'):
|
if self.config.get('general', 'auto-save-config'):
|
||||||
|
to_save.append(("config", self.config.save))
|
||||||
|
to_save += [("command history", self.cmd_history.save),
|
||||||
|
("window geometry", self._save_geometry),
|
||||||
|
("window geometry", self.stateconfig.save),
|
||||||
|
("cookies", self.cookiejar.save),
|
||||||
|
("quickmarks", quickmarks.save)]
|
||||||
|
for what, handler in to_save:
|
||||||
|
log.destroy.debug("Saving {} (handler: {})".format(
|
||||||
|
what, handler.__qualname__))
|
||||||
try:
|
try:
|
||||||
self.config.save()
|
handler()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
log.destroy.warning("Could not save config.")
|
log.destroy.warning("Could not save {}.".format(what))
|
||||||
# Save command history
|
|
||||||
try:
|
|
||||||
self.cmd_history.save()
|
|
||||||
except AttributeError:
|
|
||||||
log.destroy.warning("Could not save command history.")
|
|
||||||
# Save window state
|
|
||||||
try:
|
|
||||||
self._save_geometry()
|
|
||||||
self.stateconfig.save()
|
|
||||||
except AttributeError:
|
|
||||||
log.destroy.warning("Could not save window geometry.")
|
|
||||||
# Save cookies
|
|
||||||
try:
|
|
||||||
self.cookiejar.save()
|
|
||||||
except AttributeError:
|
|
||||||
log.destroy.warning("Could not save cookies.")
|
|
||||||
# Save quickmarks
|
|
||||||
try:
|
|
||||||
quickmarks.save()
|
|
||||||
except AttributeError:
|
|
||||||
log.destroy.warning("Could not save quickmarks.")
|
|
||||||
# Shut down tabs
|
# Shut down tabs
|
||||||
try:
|
try:
|
||||||
self.mainwindow.tabs.shutdown_complete.connect(partial(
|
self.mainwindow.tabs.shutdown_complete.connect(partial(
|
||||||
@ -632,8 +620,8 @@ class QuteBrowser(QApplication):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
log.destroy.warning("No networkmanager to shut down.")
|
log.destroy.warning("No networkmanager to shut down.")
|
||||||
self._maybe_quit('networkmanager')
|
self._maybe_quit('networkmanager')
|
||||||
|
# Re-enable faulthandler to stdout, then remove crash log
|
||||||
if self._crashlogfile is not None:
|
if self._crashlogfile is not None:
|
||||||
# Re-enable faulthandler to stdout, then remove crash log
|
|
||||||
if sys.stderr is not None:
|
if sys.stderr is not None:
|
||||||
faulthandler.enable()
|
faulthandler.enable()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user