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
This commit is contained in:
Marco Trevisan (Treviño) 2017-10-28 02:23:02 -05:00
parent 9dc977e324
commit a46af9edf0

View File

@ -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];