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
@ -22,8 +22,6 @@ var CloseDialog = GObject.registerClass({
|
||||
this._dialog = null;
|
||||
this._tracked = undefined;
|
||||
this._timeoutId = 0;
|
||||
this._windowFocusChangedId = 0;
|
||||
this._keyFocusChangedId = 0;
|
||||
}
|
||||
|
||||
get window() {
|
||||
@ -155,13 +153,11 @@ var CloseDialog = GObject.registerClass({
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
});
|
||||
|
||||
this._windowFocusChangedId =
|
||||
global.display.connect('notify::focus-window',
|
||||
this._onFocusChanged.bind(this));
|
||||
global.display.connectObject(
|
||||
'notify::focus-window', this._onFocusChanged.bind(this), this);
|
||||
|
||||
this._keyFocusChangedId =
|
||||
global.stage.connect('notify::key-focus',
|
||||
this._onFocusChanged.bind(this));
|
||||
global.stage.connectObject(
|
||||
'notify::key-focus', this._onFocusChanged.bind(this), this);
|
||||
|
||||
this._addWindowEffect();
|
||||
this._initDialog();
|
||||
@ -186,11 +182,8 @@ var CloseDialog = GObject.registerClass({
|
||||
GLib.source_remove(this._timeoutId);
|
||||
this._timeoutId = 0;
|
||||
|
||||
global.display.disconnect(this._windowFocusChangedId);
|
||||
this._windowFocusChangedId = 0;
|
||||
|
||||
global.stage.disconnect(this._keyFocusChangedId);
|
||||
this._keyFocusChangedId = 0;
|
||||
global.display.disconnectObject(this);
|
||||
global.stage.disconnectObject(this);
|
||||
|
||||
this._dialog._dialog.remove_all_transitions();
|
||||
|
||||
|
Reference in New Issue
Block a user