Skip to content

Commit

Permalink
fix: disconnect signal from layoutManager when extension is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
flexagoon committed Sep 26, 2024
1 parent 5d0eb93 commit 63d14d7
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class RoundedWindowCornersReborn extends Extension {
private _orig_finish_workspace_swt!: typeof WorkspaceAnimationController.prototype._finishWorkspaceSwitch;

private _windowPicker: WindowPicker | null = null;
private _layoutManagerStartupConnection: number | null = null;

enable() {
initPrefs(this.getSettings());
Expand All @@ -62,13 +63,21 @@ export default class RoundedWindowCornersReborn extends Extension {
// 21d4bbde15acf7c3bf348f7375a12f7b14c3ab6f/src/extension.js#L87

if (layoutManager._startingUp) {
const connection = layoutManager.connect('startup-complete', () => {
enableEffect();
if (getPref('enable-preferences-entry')) {
enableBackgroundMenuItem();
}
layoutManager.disconnect(connection);
});
this._layoutManagerStartupConnection = layoutManager.connect(
'startup-complete',
() => {
enableEffect();
if (getPref('enable-preferences-entry')) {
enableBackgroundMenuItem();
}
layoutManager.disconnect(
// Since this happens inside of the connection, there
// is no way for this to be null.
// biome-ignore lint/style/noNonNullAssertion:
this._layoutManagerStartupConnection!,
);
},
);
} else {
enableEffect();
if (getPref('enable-preferences-entry')) {
Expand Down Expand Up @@ -304,6 +313,11 @@ export default class RoundedWindowCornersReborn extends Extension {
// Set all props to null
this._windowPicker = null;

if (this._layoutManagerStartupConnection !== null) {
layoutManager.disconnect(this._layoutManagerStartupConnection);
this._layoutManagerStartupConnection = null;
}

logDebug('Disabled');

uninitPrefs();
Expand Down

0 comments on commit 63d14d7

Please sign in to comment.