Blame SOURCES/fix-session-save-crash.patch

e47e58
From 0c9cb02111908409285991e4b0f44a4fdcf91eed Mon Sep 17 00:00:00 2001
e47e58
From: Olivier Fourdan <ofourdan@redhat.com>
e47e58
Date: Tue, 23 Jan 2018 11:43:09 +0100
e47e58
Subject: [PATCH 1/2] session: use initial workspace if no workspace set
e47e58
MIME-Version: 1.0
e47e58
Content-Type: text/plain; charset=UTF-8
e47e58
Content-Transfer-Encoding: 8bit
e47e58
e47e58
Having “on_all_workspaces_requested” FALSE on a window does not imply a
e47e58
workspace is set.
e47e58
e47e58
If the X11 window is placed on a secondary monitor while workspaces
e47e58
applies on primary monitor only  (“workspaces-only-on-primary” set) then
e47e58
“on_all_workspaces_requested” is FALSE while “on_all_workspaces“ is TRUE
e47e58
and the associated workspace is NULL, leading to a crash when saving the
e47e58
gnome-shell/mutter session.
e47e58
e47e58
So if no workspace is set, use the “initial_workspace” instead to avoid
e47e58
a NULL pointer dereference.
e47e58
e47e58
https://bugzilla.gnome.org/show_bug.cgi?id=792818
e47e58
---
e47e58
 src/x11/session.c | 5 ++++-
e47e58
 1 file changed, 4 insertions(+), 1 deletion(-)
e47e58
e47e58
diff --git a/src/x11/session.c b/src/x11/session.c
e47e58
index af64270a6..8b2a89f1c 100644
e47e58
--- a/src/x11/session.c
e47e58
+++ b/src/x11/session.c
e47e58
@@ -950,7 +950,10 @@ save_state (void)
e47e58
               fputs ("    <sticky/>\n", outfile);
e47e58
             } else {
e47e58
               int n;
e47e58
-              n = meta_workspace_index (window->workspace);
e47e58
+              if (window->workspace)
e47e58
+                n = meta_workspace_index (window->workspace);
e47e58
+              else
e47e58
+                n = window->initial_workspace;
e47e58
               fprintf (outfile,
e47e58
                        "    <workspace index=\"%d\"/>\n", n);
e47e58
             }
e47e58
-- 
e47e58
2.14.3
e47e58
e47e58
e47e58
From e2269448dcebd24f23bb8872590204819abc3ac0 Mon Sep 17 00:00:00 2001
e47e58
From: Olivier Fourdan <ofourdan@redhat.com>
e47e58
Date: Mon, 29 Jan 2018 16:58:46 +0100
e47e58
Subject: [PATCH 2/2] =?UTF-8?q?x11/window:=20Mark=20restored=20workspace?=
e47e58
 =?UTF-8?q?=20as=20=E2=80=9Cset=E2=80=9D?=
e47e58
MIME-Version: 1.0
e47e58
Content-Type: text/plain; charset=UTF-8
e47e58
Content-Transfer-Encoding: 8bit
e47e58
e47e58
When a window's workspace is not NULL, on_all_workspace should be FALSE.
e47e58
Similarly, when on_all_workspace is TRUE, the window workspace should be
e47e58
NULL.
e47e58
e47e58
This is an assumption in multiple places in the code, including when
e47e58
setting the workspace state, the window is either added or removed from
e47e58
all workspaces only if the window's workspace is NULL.
e47e58
e47e58
This rule is initially enforced at creation in _meta_window_shared_new()
e47e58
when a initial workspace is set. However, when the initial workspace is
e47e58
set from the session info, the initial workspace is not marked as “set”
e47e58
which leads to an assertion failure when unmanaging windows, because the
e47e58
window is not removed from all the workspaces.
e47e58
e47e58
When applying the session info to a window, mark the workspace as “set”.
e47e58
e47e58
https://gitlab.gnome.org/GNOME/mutter/issues/4
e47e58
e47e58
Closes: #4
e47e58
---
e47e58
 src/x11/window-x11.c | 1 +
e47e58
 1 file changed, 1 insertion(+)
e47e58
e47e58
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
e47e58
index 36a5e70a3..9c8ef5d75 100644
e47e58
--- a/src/x11/window-x11.c
e47e58
+++ b/src/x11/window-x11.c
e47e58
@@ -466,6 +466,7 @@ meta_window_apply_session_info (MetaWindow *window,
e47e58
           MetaWorkspace *workspace = spaces->data;
e47e58
 
e47e58
           meta_window_change_workspace (window, workspace);
e47e58
+          window->initial_workspace_set = TRUE;
e47e58
 
e47e58
           meta_topic (META_DEBUG_SM,
e47e58
                       "Restoring saved window %s to workspace %d\n",
e47e58
-- 
e47e58
2.14.3
e47e58