[epiphany/mcatanzaro/#1445] window: close session immediately when closing the final window




commit 5e00d7491942896380dc00ecc77ede3088ceab30
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Wed Feb 24 12:30:39 2021 -0600

    window: close session immediately when closing the final window
    
    Otherwise we could lose the entire session if any tab is unresponsive.
    Thanks to Exalm for debugging it.
    
    Fixes #1445

 src/ephy-window.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 6882bf143..94a85420d 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -4307,6 +4307,17 @@ ephy_window_close (EphyWindow *window)
                               EPHY_PREFS_LOCKDOWN_QUIT))
     return FALSE;
 
+  /* If we are closing the last window, we must save the session state
+   * immediately, before any tabs in this window get closed. We want to
+   * avoid, for example, losing our session if a tab is unresponsive and
+   * the check modified forms timeout callback fires.
+   */
+  if (ephy_shell_get_n_windows (ephy_shell_get_default ()) == 1) {
+    session = ephy_shell_get_session (ephy_shell_get_default ());
+    if (session)
+      ephy_session_close (session);
+  }
+
   if (window->checking_modified_forms) {
     /* stop window close */
     return FALSE;
@@ -4333,7 +4344,6 @@ ephy_window_close (EphyWindow *window)
   /* If this is the last window, check ongoing downloads and save its state in the session. */
   if (ephy_shell_get_n_windows (ephy_shell_get_default ()) == 1) {
     EphyDownloadsManager *manager = ephy_embed_shell_get_downloads_manager (EPHY_EMBED_SHELL 
(ephy_shell_get_default ()));
-    EphySession *session;
 
     if (ephy_downloads_manager_has_active_downloads (manager)) {
       GList *list = ephy_downloads_manager_get_downloads (manager);
@@ -4342,10 +4352,6 @@ ephy_window_close (EphyWindow *window)
       /* stop window close */
       return FALSE;
     }
-
-    session = ephy_shell_get_session (ephy_shell_get_default ());
-    if (session)
-      ephy_session_close (session);
   }
 
   /* See bug #114689 */


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