From a867cce00a52b298d19179008bf0420b9ae268c6 Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Mon, 10 Dec 2012 13:10:27 +0100 Subject: ephy-session: fixup session autoresume This code was confusing, but what we actually wanted to do here was to only autoresume the session if there were no windows opened, otherwise it means we are launching a new instance after the first one. Make this explicit in the code instead of relying on side-effects of early returns. --- src/ephy-session.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ephy-session.c b/src/ephy-session.c index 02b37dd3a..bb58d3850 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -209,6 +209,7 @@ session_command_autoresume (EphySession *session, char *saved_session_file_path; gboolean crashed_session; EphyPrefsRestoreSessionPolicy policy; + EphyShell *shell; LOG ("ephy_session_autoresume"); @@ -222,6 +223,8 @@ session_command_autoresume (EphySession *session, policy = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_RESTORE_SESSION_POLICY); + shell = ephy_shell_get_default (); + if (crashed_session == FALSE || policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER) { @@ -234,13 +237,11 @@ session_command_autoresume (EphySession *session, ephy_session_queue_command (session, EPHY_SESSION_CMD_MAYBE_OPEN_WINDOW, NULL, NULL, user_time, FALSE); - - return; } - - ephy_session_queue_command (session, - EPHY_SESSION_CMD_LOAD_SESSION, - SESSION_STATE, NULL, user_time, TRUE); + else if (ephy_shell_get_n_windows (shell) == 0) + ephy_session_queue_command (session, + EPHY_SESSION_CMD_LOAD_SESSION, + SESSION_STATE, NULL, user_time, TRUE); } static void -- cgit v1.2.3