js: Use (dis)connectObject()

Start using the new methods to simplify signal cleanup. For now,
focus on replacing existing cleanups; in most cases this means
signals connected in the constructor and disconnected on destroy,
but also other cases with a similarly defined lifetime (say: from
show to hide).

This doesn't change signal connections that only exist for a short
time (say: once), handlers that are connected on-demand (say: the
first time a particular method is called), or connections that
aren't tracked (read: disconnected) at all.

We will eventually replace the latter with connectObject() as
well - especially from actor subclasses - but the changeset is
already big enough as-is :-)

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1953>
This commit is contained in:
Florian Müllner
2021-08-16 00:36:59 +02:00
committed by Marge Bot
parent f45ccc9143
commit 26235bbe54
54 changed files with 753 additions and 1674 deletions

View File

@ -91,15 +91,13 @@ var StreamSlider = class {
}
_disconnectStream(stream) {
stream.disconnect(this._mutedChangedId);
this._mutedChangedId = 0;
stream.disconnect(this._volumeChangedId);
this._volumeChangedId = 0;
stream.disconnectObject(this);
}
_connectStream(stream) {
this._mutedChangedId = stream.connect('notify::is-muted', this._updateVolume.bind(this));
this._volumeChangedId = stream.connect('notify::volume', this._updateVolume.bind(this));
stream.connectObject(
'notify::is-muted', this._updateVolume.bind(this),
'notify::volume', this._updateVolume.bind(this), this);
}
_shouldBeVisible() {
@ -231,7 +229,8 @@ var OutputStreamSlider = class extends StreamSlider {
_connectStream(stream) {
super._connectStream(stream);
this._portChangedId = stream.connect('notify::port', this._portChanged.bind(this));
stream.connectObject('notify::port',
this._portChanged.bind(this), this);
this._portChanged();
}
@ -250,12 +249,6 @@ var OutputStreamSlider = class extends StreamSlider {
return false;
}
_disconnectStream(stream) {
super._disconnectStream(stream);
stream.disconnect(this._portChangedId);
this._portChangedId = 0;
}
_updateSliderIcon() {
this._icon.icon_name = this._hasHeadphones
? 'audio-headphones-symbolic'