dispose and clear things out when they are not needed to free up memory (#5805)

This commit is contained in:
Anthony Dresser
2019-05-31 17:24:01 -07:00
committed by Karl Burtram
parent ba58b0f429
commit 23e4a30cd1
4 changed files with 19 additions and 34 deletions

View File

@@ -77,7 +77,7 @@ export class MessagePanel extends Disposable {
private styleElement = createStyleSheet(this.container);
private queryRunnerDisposables: IDisposable[] = [];
private _state: MessagePanelState;
private _state: MessagePanelState | undefined;
private tree: ITree;
@@ -201,7 +201,7 @@ export class MessagePanel extends Disposable {
}
// convert to old VS Code tree interface with expandable methods
let expandableTree: IExpandableTree = <IExpandableTree>this.tree;
if (this.state.scrollPosition) {
if (this.state && this.state.scrollPosition) {
const previousScroll = this.state.scrollPosition;
this.tree.refresh(this.model).then(() => {
// Restore the previous scroll position when switching between tabs
@@ -233,6 +233,7 @@ export class MessagePanel extends Disposable {
private reset() {
this.model.messages = [];
this._state = undefined;
this.model.totalExecuteMessage = undefined;
this.tree.refresh(this.model);
}

View File

@@ -24,7 +24,6 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
class MessagesView extends Disposable implements IPanelView {
private messagePanel: MessagePanel;
private container = document.createElement('div');
private _state: MessagePanelState;
constructor(private instantiationService: IInstantiationService) {
super();
@@ -59,19 +58,13 @@ class MessagesView extends Disposable implements IPanelView {
}
public set state(val: MessagePanelState) {
this._state = val;
this.messagePanel.state = val;
}
public get state(): MessagePanelState {
return this._state;
}
}
class ResultsView extends Disposable implements IPanelView {
private gridPanel: GridPanel;
private container = document.createElement('div');
private _state: GridPanelState;
constructor(private instantiationService: IInstantiationService) {
super();
@@ -106,13 +99,8 @@ class ResultsView extends Disposable implements IPanelView {
}
public set state(val: GridPanelState) {
this._state = val;
this.gridPanel.state = val;
}
public get state(): GridPanelState {
return this._state;
}
}
class ResultsTab implements IPanelTab {