Skip to content

Commit

Permalink
Properly dispose panel references (152)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Nov 13, 2024
1 parent 1c0ea10 commit 735b623
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/controllers/ExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export class ExtensionController implements Disposable {

this._serverManager.onDidDisconnect(
serverUrl => {
this._panelService?.clearServerData(serverUrl);
this._outputChannel?.appendLine(
`Disconnected from server: '${serverUrl}'.`
);
Expand Down
6 changes: 6 additions & 0 deletions src/services/PanelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ export class PanelService implements IPanelService, Disposable {
private readonly _cnPanelMap: URLMap<VariablePanelMap>;
private readonly _cnVariableMap: URLMap<VariableMap>;

clearServerData = (url: URL): void => {
this._cnPanelMap.delete(url);
this._cnVariableMap.delete(url);
};

dispose = async (): Promise<void> => {
this._cnPanelMap.clear();
this._cnVariableMap.clear();
};

/**
Expand Down
1 change: 1 addition & 0 deletions src/types/serviceTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export type IDheServiceFactory = IFactory<IDheService, [serverUrl: URL]>;
export interface IPanelService extends Disposable {
readonly onDidUpdate: vscode.Event<void>;

clearServerData: (url: URL) => void;
getPanelUrls: () => URL[];
getPanelVariables: (url: URL) => VariableDefintion[];
getPanelOrThrow: (url: URL, variableId: VariableID) => vscode.WebviewPanel;
Expand Down

0 comments on commit 735b623

Please sign in to comment.