extensions: Stop using run_dispose()
It is considered bad practice, and mainly a lazy way of disconnecting signal handlers without tracking individual handler IDs. We can do better by using connectObject(), which provides the same level of convenience without the dodginess of getting behind the garbage collector's back. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/275>
This commit is contained in:
committed by
Marge Bot
parent
4fbd878208
commit
2510bb3625
@@ -22,7 +22,8 @@ class WindowMover {
|
||||
this._appSystem.connectObject('installed-changed',
|
||||
() => this._updateAppData(), this);
|
||||
|
||||
this._settings.connect('changed', this._updateAppConfigs.bind(this));
|
||||
this._settings.connectObject('changed',
|
||||
this._updateAppConfigs.bind(this), this);
|
||||
this._updateAppConfigs();
|
||||
}
|
||||
|
||||
@@ -58,11 +59,8 @@ class WindowMover {
|
||||
|
||||
destroy() {
|
||||
this._appSystem.disconnectObject(this);
|
||||
|
||||
if (this._settings) {
|
||||
this._settings.run_dispose();
|
||||
this._settings = null;
|
||||
}
|
||||
this._settings.disconnectObject(this);
|
||||
this._settings = null;
|
||||
|
||||
this._appConfigs.clear();
|
||||
this._updateAppData();
|
||||
|
||||
@@ -141,8 +141,8 @@ class RootInfo extends PlaceInfo {
|
||||
return;
|
||||
|
||||
this._proxy = obj;
|
||||
this._proxy.connect('g-properties-changed',
|
||||
this._propertiesChanged.bind(this));
|
||||
this._proxy.connectObject('g-properties-changed',
|
||||
this._propertiesChanged.bind(this), this);
|
||||
this._propertiesChanged(obj);
|
||||
});
|
||||
}
|
||||
@@ -161,10 +161,8 @@ class RootInfo extends PlaceInfo {
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this._proxy) {
|
||||
this._proxy.run_dispose();
|
||||
this._proxy = null;
|
||||
}
|
||||
this._proxy?.disconnectObject(this);
|
||||
this._proxy = null;
|
||||
super.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,12 +21,13 @@ const SETTINGS_KEY = 'name';
|
||||
export default class ThemeManager extends Extension {
|
||||
enable() {
|
||||
this._settings = this.getSettings();
|
||||
this._settings.connect(`changed::${SETTINGS_KEY}`, this._changeTheme.bind(this));
|
||||
this._settings.connectObject(`changed::${SETTINGS_KEY}`,
|
||||
this._changeTheme.bind(this), this);
|
||||
this._changeTheme();
|
||||
}
|
||||
|
||||
disable() {
|
||||
this._settings?.run_dispose();
|
||||
this._settings?.disconnectObject();
|
||||
this._settings = null;
|
||||
|
||||
Main.setThemeStylesheet(null);
|
||||
|
||||
@@ -36,7 +36,7 @@ class UserThemePrefsWidget extends Adw.PreferencesGroup {
|
||||
this._actionGroup.add_action(
|
||||
this._settings.create_action('name'));
|
||||
|
||||
this.connect('destroy', () => this._settings.run_dispose());
|
||||
this.connect('destroy', () => (this._settings = null));
|
||||
|
||||
this._rows = new Map();
|
||||
this._addTheme(''); // default
|
||||
|
||||
@@ -844,8 +844,8 @@ class WindowList extends St.Widget {
|
||||
this._dndWindow = null;
|
||||
|
||||
this._settings = settings;
|
||||
this._settings.connect('changed::grouping-mode',
|
||||
() => this._groupingModeChanged());
|
||||
this._settings.connectObject('changed::grouping-mode',
|
||||
() => this._groupingModeChanged(), this);
|
||||
this._grouped = undefined;
|
||||
this._groupingModeChanged();
|
||||
}
|
||||
@@ -1092,7 +1092,8 @@ class WindowList extends St.Widget {
|
||||
|
||||
this._stopMonitoringDrag();
|
||||
|
||||
this._settings.run_dispose();
|
||||
this._settings.disconnectObject();
|
||||
this._settings = null;
|
||||
|
||||
let windows = global.get_window_actors();
|
||||
for (let i = 0; i < windows.length; i++)
|
||||
@@ -1144,8 +1145,9 @@ export default class WindowListExtension extends Extension {
|
||||
if (!this._windowLists)
|
||||
return;
|
||||
|
||||
this._settings.disconnectObject(this);
|
||||
Main.layoutManager.disconnectObject(this);
|
||||
this._settings.disconnectObject(this);
|
||||
this._settings = null;
|
||||
|
||||
this._windowLists.forEach(windowList => {
|
||||
windowList.hide();
|
||||
|
||||
Reference in New Issue
Block a user