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:

committed by
Marge Bot

parent
f45ccc9143
commit
26235bbe54
@ -171,21 +171,14 @@ class ScaleLayout extends Clutter.BinLayout {
|
||||
if (this._container == container)
|
||||
return;
|
||||
|
||||
if (this._container) {
|
||||
for (let id of this._signals)
|
||||
this._container.disconnect(id);
|
||||
}
|
||||
this._container?.disconnectObject(this);
|
||||
|
||||
this._container = container;
|
||||
this._signals = [];
|
||||
|
||||
if (this._container) {
|
||||
for (let signal of ['notify::scale-x', 'notify::scale-y']) {
|
||||
let id = this._container.connect(signal, () => {
|
||||
this.layout_changed();
|
||||
});
|
||||
this._signals.push(id);
|
||||
}
|
||||
this._container.connectObject(
|
||||
'notify::scale-x', () => this.layout_changed(),
|
||||
'notify::scale-y', () => this.layout_changed(), this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -586,11 +579,8 @@ var MessageListSection = GObject.registerClass({
|
||||
this._list.connect('actor-added', this._sync.bind(this));
|
||||
this._list.connect('actor-removed', this._sync.bind(this));
|
||||
|
||||
let id = Main.sessionMode.connect('updated',
|
||||
this._sync.bind(this));
|
||||
this.connect('destroy', () => {
|
||||
Main.sessionMode.disconnect(id);
|
||||
});
|
||||
Main.sessionMode.connectObject(
|
||||
'updated', () => this._sync(), this);
|
||||
|
||||
this._empty = true;
|
||||
this._canClear = false;
|
||||
|
Reference in New Issue
Block a user