[epiphany/wip/fixes: 5/15] session: Check restore-session-policy in ephy_session_save()



commit 75d1c57a63c394704831d4765d69c6db042cb428
Author: Michael Catanzaro <mcatanzaro igalia com>
Date:   Sat Mar 5 14:18:09 2016 -0600

    session: Check restore-session-policy in ephy_session_save()
    
    Instead of doing it in the idle, it's better to do it here before
    scheduling the unnecessary idle. Currently it's handled in the idle
    because the idle is called manually from ephy_session_close() and this
    saves checking it in both places, but now that we need to check it in
    ephy_session_close() anyway, there's no value in doing it in the idle.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762906

 src/ephy-session.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/ephy-session.c b/src/ephy-session.c
index f2bf88c..afdc2e0 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -935,7 +935,6 @@ ephy_session_save_idle_cb (EphySession *session)
        EphyShell *shell = ephy_shell_get_default ();
        SaveData *data;
        GTask *task;
-       EphyPrefsRestoreSessionPolicy policy;
 
        session->save_source_id = 0;
 
@@ -946,12 +945,6 @@ ephy_session_save_idle_cb (EphySession *session)
                session->save_cancellable = NULL;
        }
 
-       policy = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_RESTORE_SESSION_POLICY);
-       if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER)
-       {
-               return G_SOURCE_REMOVE;
-       }
-
        LOG ("ephy_sesion_save");
 
        if (ephy_shell_get_n_windows (shell) == 0)
@@ -975,6 +968,8 @@ ephy_session_save_idle_cb (EphySession *session)
 void
 ephy_session_save (EphySession *session)
 {
+       EphyPrefsRestoreSessionPolicy policy;
+
        g_return_if_fail (EPHY_IS_SESSION (session));
 
        if (session->save_source_id)
@@ -987,6 +982,12 @@ ephy_session_save (EphySession *session)
                return;
        }
 
+       policy = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_RESTORE_SESSION_POLICY);
+       if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER)
+       {
+               return;
+       }
+
        session->save_source_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 1,
                                                              (GSourceFunc)ephy_session_save_idle_cb,
                                                              ephy_session_save_idle_started (session),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]