[gnome-shell/gnome-3-38] workspace: Check if index is valid before using it
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-38] workspace: Check if index is valid before using it
- Date: Thu, 11 Mar 2021 12:51:05 +0000 (UTC)
commit c31df1f08a7a4921d8b9711bf2bf8358a0b6e13a
Author: Ivan Molodetskikh <yalterz gmail com>
Date: Sat Feb 27 09:59:21 2021 +0300
workspace: Check if index is valid before using it
If the window wasn't in _windowSlots, the index is -1, so the last
element of the array is removed, leading to
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3547
I logged the stack trace from removeWindow() and it seems that when you
move the window from the second monitor to another workspace like shown
in https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3547,
removeWindow() is called twice for it, presumably once for the second
monitor workspace, and then once for the first monitor workspace for
some reason. It is during that call that _windowSlots doesn't contain
the window, so instead the last element (index -1) is removed, leading
to the animation bug.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1727>
(cherry picked from commit 35fb221a7ea99cbc0a7f50782c2b52ab461a21ab)
js/ui/workspace.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index 04ffc99cab..6cd6a985c9 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -736,8 +736,9 @@ var WorkspaceLayout = GObject.registerClass({
// The layout might be frozen and we might not update the windowSlots
// on the next allocation, so remove the slot now already
- this._windowSlots.splice(
- this._windowSlots.findIndex(s => s[4] === window), 1);
+ const index = this._windowSlots.findIndex(s => s[4] === window);
+ if (index !== -1)
+ this._windowSlots.splice(index, 1);
// The window might have been reparented by DND
if (window.get_parent() === this._container)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]