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

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