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
@ -891,12 +891,10 @@ var LayoutManager = GObject.registerClass({
|
||||
|
||||
let actorData = Params.parse(params, defaultParams);
|
||||
actorData.actor = actor;
|
||||
actorData.visibleId = actor.connect('notify::visible',
|
||||
this._queueUpdateRegions.bind(this));
|
||||
actorData.allocationId = actor.connect('notify::allocation',
|
||||
this._queueUpdateRegions.bind(this));
|
||||
actorData.destroyId = actor.connect('destroy',
|
||||
this._untrackActor.bind(this));
|
||||
actor.connectObject(
|
||||
'notify::visible', this._queueUpdateRegions.bind(this),
|
||||
'notify::allocation', this._queueUpdateRegions.bind(this),
|
||||
'destroy', this._untrackActor.bind(this), this);
|
||||
// Note that destroying actor will unset its parent, so we don't
|
||||
// need to connect to 'destroy' too.
|
||||
|
||||
@ -910,12 +908,9 @@ var LayoutManager = GObject.registerClass({
|
||||
|
||||
if (i == -1)
|
||||
return;
|
||||
let actorData = this._trackedActors[i];
|
||||
|
||||
this._trackedActors.splice(i, 1);
|
||||
actor.disconnect(actorData.visibleId);
|
||||
actor.disconnect(actorData.allocationId);
|
||||
actor.disconnect(actorData.destroyId);
|
||||
actor.disconnectObject(this);
|
||||
|
||||
this._queueUpdateRegions();
|
||||
}
|
||||
|
Reference in New Issue
Block a user