From a33aa524defa7605b1169b01f2ab6270c479f12b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 10 Apr 2016 17:47:14 +0200 Subject: [PATCH] Don't crash if data is None while saving session Under some circumstances I can't reproduce (switching/turning off monitors?) it seems it's possible that SessionManager.save gets called with last_window=True, without on_last_window_closed being called. This might be to one of the Qt screen management bugs fixed in Qt 5.6, which would explain why I can't reproduce it. Instead of crashing, let's log the error and not save the session. --- qutebrowser/misc/sessions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index d9937f66f..72a9b7224 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -241,7 +241,9 @@ class SessionManager(QObject): log.sessions.debug("Saving session {} to {}...".format(name, path)) if last_window: data = self._last_window_session - assert data is not None + if data is None: + log.sessions.error("last_window_session is None while saving!") + return else: data = self._save_all() log.sessions.vdebug("Saving data: {}".format(data))