fix(session): save the last session before the windows are torn down
The save ran from the cleanup path, after the quit request had already made the C side close every OS window, so the serialized session was always empty. Save from the quit paths instead, where the windows still exist, and keep the cleanup path as a no-op fallback.
This commit is contained in:
1 file changed
+12
@@ -2528,6 +2528,7 @@ class Boss:
|
||||
if not self._call_on_quit_watchers({'confirmed': True}):
|
||||
set_application_quit_request(NO_CLOSE_REQUESTED)
|
||||
return
|
||||
self.save_last_session()
|
||||
self.save_session_if_logging_out()
|
||||
set_application_quit_request(IMPERATIVE_CLOSE_REQUESTED)
|
||||
return
|
||||
@@ -2557,9 +2558,20 @@ class Boss:
|
||||
if not self._call_on_quit_watchers({'confirmed': True}):
|
||||
set_application_quit_request(NO_CLOSE_REQUESTED)
|
||||
return
|
||||
self.save_last_session()
|
||||
self.save_session_if_logging_out()
|
||||
set_application_quit_request(IMPERATIVE_CLOSE_REQUESTED if confirmed else NO_CLOSE_REQUESTED)
|
||||
|
||||
def save_last_session(self) -> None:
|
||||
# Must run before the quit request is set: the C side then closes the windows and there is
|
||||
# nothing left to serialize. Saving an empty session is a no-op, so this never clobbers a
|
||||
# good state with a torn down one.
|
||||
from .main import is_panel_kitten
|
||||
from .session_restore import save_session_of
|
||||
|
||||
if not is_panel_kitten():
|
||||
save_session_of(self)
|
||||
|
||||
def save_session_if_logging_out(self) -> None:
|
||||
from .logout_session import is_logout_in_progress
|
||||
|
||||
|
||||
Reference in new issue
Block a user