Fix saving geometry if mainwindow is closed on shutdown. Fixes #159.

This commit is contained in:
Florian Bruhin 2014-10-08 22:03:12 +02:00
parent cb951643b6
commit cbdade6518
2 changed files with 11 additions and 11 deletions

View File

@ -59,6 +59,7 @@ class Application(QApplication):
_crashdlg: The crash dialog currently open.
_crashlogfile: A file handler to the fatal crash logfile.
_event_filter: The EventFilter for the application.
geometry: The geometry of the last closed main window.
"""
def __init__(self, args):
@ -72,6 +73,7 @@ class Application(QApplication):
'tabs': False,
'main': False,
}
self.geometry = None
self._shutting_down = False
self._crashdlg = None
self._crashlogfile = None
@ -367,12 +369,9 @@ class Application(QApplication):
def _save_geometry(self):
"""Save the window geometry to the state config."""
last_win_id = sorted(objreg.window_registry)[-1]
main_window = objreg.get('main-window', scope='window',
window=last_win_id)
if self.geometry is not None:
state_config = objreg.get('state-config')
data = bytes(main_window.saveGeometry())
geom = base64.b64encode(data).decode('ASCII')
geom = base64.b64encode(self.geometry).decode('ASCII')
try:
state_config.add_section('geometry')
except configparser.DuplicateSectionError:

View File

@ -330,4 +330,5 @@ class MainWindow(QWidget):
e.ignore()
return
e.accept()
objreg.get('app').geometry = bytes(self.saveGeometry())
log.destroy.debug("Closing window {}".format(self.win_id))