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
@ -55,8 +55,6 @@ var BoxPointer = GObject.registerClass({
|
||||
else
|
||||
Meta.enable_unredirect_for_display(global.display);
|
||||
});
|
||||
|
||||
this.connect('destroy', this._onDestroy.bind(this));
|
||||
}
|
||||
|
||||
vfunc_captured_event(event) {
|
||||
@ -74,13 +72,6 @@ var BoxPointer = GObject.registerClass({
|
||||
return Clutter.EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
_onDestroy() {
|
||||
if (this._sourceActorDestroyId) {
|
||||
this._sourceActor.disconnect(this._sourceActorDestroyId);
|
||||
delete this._sourceActorDestroyId;
|
||||
}
|
||||
}
|
||||
|
||||
get arrowSide() {
|
||||
return this._arrowSide;
|
||||
}
|
||||
@ -439,19 +430,12 @@ var BoxPointer = GObject.registerClass({
|
||||
|
||||
setPosition(sourceActor, alignment) {
|
||||
if (!this._sourceActor || sourceActor != this._sourceActor) {
|
||||
if (this._sourceActorDestroyId) {
|
||||
this._sourceActor.disconnect(this._sourceActorDestroyId);
|
||||
delete this._sourceActorDestroyId;
|
||||
}
|
||||
this._sourceActor?.disconnectObject(this);
|
||||
|
||||
this._sourceActor = sourceActor;
|
||||
|
||||
if (this._sourceActor) {
|
||||
this._sourceActorDestroyId = this._sourceActor.connect('destroy', () => {
|
||||
this._sourceActor = null;
|
||||
delete this._sourceActorDestroyId;
|
||||
});
|
||||
}
|
||||
this._sourceActor?.connectObject('destroy',
|
||||
() => (this._sourceActor = null), this);
|
||||
}
|
||||
|
||||
this._arrowAlignment = alignment;
|
||||
|
Reference in New Issue
Block a user