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
@ -31,22 +31,19 @@ var AutomountManager = class {
|
||||
}
|
||||
|
||||
enable() {
|
||||
this._volumeAddedId = this._volumeMonitor.connect('volume-added', this._onVolumeAdded.bind(this));
|
||||
this._volumeRemovedId = this._volumeMonitor.connect('volume-removed', this._onVolumeRemoved.bind(this));
|
||||
this._driveConnectedId = this._volumeMonitor.connect('drive-connected', this._onDriveConnected.bind(this));
|
||||
this._driveDisconnectedId = this._volumeMonitor.connect('drive-disconnected', this._onDriveDisconnected.bind(this));
|
||||
this._driveEjectButtonId = this._volumeMonitor.connect('drive-eject-button', this._onDriveEjectButton.bind(this));
|
||||
this._volumeMonitor.connectObject(
|
||||
'volume-added', this._onVolumeAdded.bind(this),
|
||||
'volume-removed', this._onVolumeRemoved.bind(this),
|
||||
'drive-connected', this._onDriveConnected.bind(this),
|
||||
'drive-disconnected', this._onDriveDisconnected.bind(this),
|
||||
'drive-eject-button', this._onDriveEjectButton.bind(this), this);
|
||||
|
||||
this._mountAllId = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._startupMountAll.bind(this));
|
||||
GLib.Source.set_name_by_id(this._mountAllId, '[gnome-shell] this._startupMountAll');
|
||||
}
|
||||
|
||||
disable() {
|
||||
this._volumeMonitor.disconnect(this._volumeAddedId);
|
||||
this._volumeMonitor.disconnect(this._volumeRemovedId);
|
||||
this._volumeMonitor.disconnect(this._driveConnectedId);
|
||||
this._volumeMonitor.disconnect(this._driveDisconnectedId);
|
||||
this._volumeMonitor.disconnect(this._driveEjectButtonId);
|
||||
this._volumeMonitor.disconnectObject(this);
|
||||
|
||||
if (this._mountAllId > 0) {
|
||||
GLib.source_remove(this._mountAllId);
|
||||
|
Reference in New Issue
Block a user