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
@ -94,8 +94,7 @@ var WindowPreview = GObject.registerClass({
|
||||
this.emit('size-changed');
|
||||
});
|
||||
|
||||
this._windowDestroyId =
|
||||
this._windowActor.connect('destroy', () => this.destroy());
|
||||
this._windowActor.connectObject('destroy', () => this.destroy(), this);
|
||||
|
||||
this._updateAttachedDialogs();
|
||||
|
||||
@ -177,9 +176,9 @@ var WindowPreview = GObject.registerClass({
|
||||
}));
|
||||
this._title.clutter_text.ellipsize = Pango.EllipsizeMode.END;
|
||||
this.label_actor = this._title;
|
||||
this._updateCaptionId = this.metaWindow.connect('notify::title', () => {
|
||||
this._title.text = this._getCaption();
|
||||
});
|
||||
this.metaWindow.connectObject(
|
||||
'notify::title', () => (this._title.text = this._getCaption()),
|
||||
this);
|
||||
|
||||
const layout = Meta.prefs_get_button_layout();
|
||||
this._closeButtonSide =
|
||||
@ -213,10 +212,8 @@ var WindowPreview = GObject.registerClass({
|
||||
this.add_child(this._icon);
|
||||
this.add_child(this._closeButton);
|
||||
|
||||
this._adjustmentChangedId =
|
||||
this._overviewAdjustment.connect('notify::value', () => {
|
||||
this._updateIconScale();
|
||||
});
|
||||
this._overviewAdjustment.connectObject(
|
||||
'notify::value', () => this._updateIconScale(), this);
|
||||
this._updateIconScale();
|
||||
|
||||
this.connect('notify::realized', () => {
|
||||
@ -526,13 +523,9 @@ var WindowPreview = GObject.registerClass({
|
||||
}
|
||||
|
||||
_onDestroy() {
|
||||
this._windowActor.disconnect(this._windowDestroyId);
|
||||
|
||||
this.metaWindow._delegate = null;
|
||||
this._delegate = null;
|
||||
|
||||
this.metaWindow.disconnect(this._updateCaptionId);
|
||||
|
||||
if (this._longPressLater) {
|
||||
Meta.later_remove(this._longPressLater);
|
||||
delete this._longPressLater;
|
||||
@ -543,11 +536,6 @@ var WindowPreview = GObject.registerClass({
|
||||
this._idleHideOverlayId = 0;
|
||||
}
|
||||
|
||||
if (this._adjustmentChangedId > 0) {
|
||||
this._overviewAdjustment.disconnect(this._adjustmentChangedId);
|
||||
this._adjustmentChangedId = 0;
|
||||
}
|
||||
|
||||
if (this.inDrag) {
|
||||
this.emit('drag-end');
|
||||
this.inDrag = false;
|
||||
|
Reference in New Issue
Block a user