[gnome-text-editor] session: always restore pages/drafts after crash
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] session: always restore pages/drafts after crash
- Date: Sun, 19 Jun 2022 21:14:48 +0000 (UTC)
commit 5973dc24a77eafc5da652f77e5df72eeb670a8f8
Author: Christian Hergert <chergert redhat com>
Date: Sun Jun 19 14:14:40 2022 -0700
session: always restore pages/drafts after crash
Fixes #403
src/editor-session.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/editor-session.c b/src/editor-session.c
index 92f83c1..c316ada 100644
--- a/src/editor-session.c
+++ b/src/editor-session.c
@@ -1736,6 +1736,8 @@ editor_session_restore_v1 (EditorSession *self,
GVariantIter iter;
GVariant *window;
gboolean had_failure = FALSE;
+ gboolean restore_pages;
+ gboolean did_shutdown = TRUE;
guint width, height;
g_assert (EDITOR_IS_SESSION (self));
@@ -1752,7 +1754,16 @@ editor_session_restore_v1 (EditorSession *self,
default_height = height;
}
- if (!self->restore_pages ||
+ /* Check if the application crashed. If shutdown==false, then we auto-saved
+ * session state but did not shutdown gracefully. We always restore pages in
+ * that case to avoid data loss of drafts. (Technically they're there, but the
+ * user wouldn't be able to find them unless session-restore is active).
+ */
+ restore_pages = self->restore_pages;
+ if (g_variant_lookup (state, "shutdown", "b", &did_shutdown) && !did_shutdown)
+ restore_pages = TRUE;
+
+ if (!restore_pages ||
!(windows = g_variant_lookup_value (state, "windows", G_VARIANT_TYPE ("aa{sv}"))) ||
g_variant_n_children (windows) == 0)
goto failure;
@@ -1821,7 +1832,7 @@ editor_session_restore_v1 (EditorSession *self,
return;
failure:
- if (!self->restore_pages)
+ if (!restore_pages)
g_debug ("Failed to restore session or nothing to restore");
editor_session_create_window (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]