diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index 980019cd4..ef2a6049b 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -832,6 +832,8 @@ var InputSourceIndicator = new Lang.Class({ _init() { this.parent(0.0, _("Keyboard")); + this.connect('destroy', this._onDestroy.bind(this)); + this._menuItems = {}; this._indicatorLabels = {}; @@ -856,11 +858,21 @@ var InputSourceIndicator = new Lang.Class({ this._sessionUpdated(); this._inputSourceManager = getInputSourceManager(); - this._inputSourceManager.connect('sources-changed', this._sourcesChanged.bind(this)); - this._inputSourceManager.connect('current-source-changed', this._currentSourceChanged.bind(this)); + this._inputSourceManagerSourcesChangedId = + this._inputSourceManager.connect('sources-changed', this._sourcesChanged.bind(this)); + this._inputSourceManagerCurrentSourceChangedId = + this._inputSourceManager.connect('current-source-changed', this._currentSourceChanged.bind(this)); this._inputSourceManager.reload(); }, + _onDestroy() { + if (this._inputSourceManager) { + this._inputSourceManager.disconnect(this._inputSourceManagerSourcesChangedId); + this._inputSourceManager.disconnect(this._inputSourceManagerCurrentSourceChangedId); + this._inputSourceManager = null; + } + }, + _sessionUpdated() { // re-using "allowSettings" for the keyboard layout is a bit shady, // but at least for now it is used as "allow popping up windows