appMenu: Clean up on destroy

For now the menu is only used in the top bar, where we can assume
that it exists "forever". This won't be the case when we start
reusing it elsewhere, so make sure we clean up after ourselves.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1948>
This commit is contained in:
Florian Müllner 2021-08-12 00:24:02 +02:00 committed by Marge Bot
parent 1550976c51
commit 07daa95393

View File

@ -55,8 +55,12 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
this.addAction(_('Quit'), () => this._app.request_quit()); this.addAction(_('Quit'), () => this._app.request_quit());
this._signals = [];
this._signals.push([
this._appSystem,
this._appSystem.connect('installed-changed', this._appSystem.connect('installed-changed',
() => this._updateDetailsVisibility()); () => this._updateDetailsVisibility()),
]);
this._updateDetailsVisibility(); this._updateDetailsVisibility();
} }
@ -65,6 +69,17 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
this._detailsItem.visible = sw !== null; this._detailsItem.visible = sw !== null;
} }
/** */
destroy() {
super.destroy();
for (const [obj, id] of this._signals)
obj.disconnect(id);
this._signals = [];
this.setApp(null);
}
/** /**
* @returns {bool} - true if the menu is empty * @returns {bool} - true if the menu is empty
*/ */