From 3b4be770a0590bcee9c739f3d9264320e23d555b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Sat, 28 Oct 2017 02:23:02 -0500 Subject: [PATCH] status/keyboard: Reset menuItems and Label objects on change In the current code it could happen that we've menuItems and indicatorLabels for sources that aren't anymore around, because in case a source is removed we don't cleanup the their container objects. Also, we should nullify InputManager's _currentSource when sources change or it might point to some invalid data again. So it could happen that we try to access an invalid menuitem or label if a source change happens mentioning a source that has been deleted. https://bugzilla.gnome.org/show_bug.cgi?id=788931 --- js/ui/status/keyboard.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index 70e6abf87..b2f10322d 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -529,6 +529,7 @@ var InputSourceManager = new Lang.Class({ let sources = this._settings.inputSources; let nSources = sources.length; + this._currentSource = null; this._inputSources = {}; this._ibusSources = {}; @@ -827,6 +828,9 @@ var InputSourceIndicator = new Lang.Class({ for (let i in this._indicatorLabels) this._indicatorLabels[i].destroy(); + this._menuItems = {}; + this._indicatorLabels = {}; + let menuIndex = 0; for (let i in this._inputSourceManager.inputSources) { let is = this._inputSourceManager.inputSources[i];