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
@ -67,8 +67,6 @@ class BaseIcon extends Shell.SquareBin {
|
||||
|
||||
super._init({ style_class: styleClass });
|
||||
|
||||
this.connect('destroy', this._onDestroy.bind(this));
|
||||
|
||||
this._box = new St.BoxLayout({
|
||||
vertical: true,
|
||||
x_expand: true,
|
||||
@ -99,7 +97,8 @@ class BaseIcon extends Shell.SquareBin {
|
||||
this.icon = null;
|
||||
|
||||
let cache = St.TextureCache.get_default();
|
||||
this._iconThemeChangedId = cache.connect('icon-theme-changed', this._onIconThemeChanged.bind(this));
|
||||
cache.connectObject(
|
||||
'icon-theme-changed', this._onIconThemeChanged.bind(this), this);
|
||||
}
|
||||
|
||||
// This can be overridden by a subclass, or by the createIcon
|
||||
@ -148,14 +147,6 @@ class BaseIcon extends Shell.SquareBin {
|
||||
this._createIconTexture(size);
|
||||
}
|
||||
|
||||
_onDestroy() {
|
||||
if (this._iconThemeChangedId > 0) {
|
||||
let cache = St.TextureCache.get_default();
|
||||
cache.disconnect(this._iconThemeChangedId);
|
||||
this._iconThemeChangedId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
_onIconThemeChanged() {
|
||||
this._createIconTexture(this.iconSize);
|
||||
}
|
||||
@ -690,13 +681,12 @@ var IconGridLayout = GObject.registerClass({
|
||||
}
|
||||
|
||||
vfunc_set_container(container) {
|
||||
if (this._container)
|
||||
this._container.disconnect(this._containerDestroyedId);
|
||||
this._container?.disconnectObject(this);
|
||||
|
||||
this._container = container;
|
||||
|
||||
if (this._container)
|
||||
this._containerDestroyedId = this._container.connect('destroy', this._onDestroy.bind(this));
|
||||
this._container.connectObject('destroy', this._onDestroy.bind(this), this);
|
||||
}
|
||||
|
||||
vfunc_get_preferred_width(_container, _forHeight) {
|
||||
|
Reference in New Issue
Block a user