From 5100458c1bc00ba14b7beabaed98c872ac8d7402 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 30 Apr 2019 12:08:25 +0000 Subject: [PATCH] keyboard: Destroy old layout actors when regenerating keyboard groups We were cleaning up self._groups, but the actors for all previous groups/layers/modes would remain attached to the aspect container, simply hidden. Under some circumstances this can really make the amount of actors in the shell stage to quickly ramp up, it's not just a "leak" but also has potential side effects on performance. We should destroy all child actors of this._aspectContainer, except the static ones (emoji and keypad). While at it, fix this._groups re-initialization, as it's actually an object, not an array. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/523 Closes?: https://gitlab.gnome.org/GNOME/mutter/issues/556 (cherry picked from commit ed999ce92693b8f1ab4040444a3e6e380e7b4475) --- js/ui/keyboard.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 8dc1b306f..c4ac72d1d 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -1470,7 +1470,12 @@ var Keyboard = class Keyboard { } _onKeyboardGroupsChanged(keyboard) { - this._groups = []; + let nonGroupActors = [this._emojiSelection.actor, this._keypad.actor]; + this._aspectContainer.get_children().filter(c => !nonGroupActors.includes(c)).forEach(c => { + c.destroy(); + }); + + this._groups = {}; this._onGroupChanged(); }