mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-13 17:22:15 -05:00
dispose and clear things out when they are not needed to free up memory (#5805)
This commit is contained in:
committed by
Karl Burtram
parent
ba58b0f429
commit
23e4a30cd1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, dispose, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
@@ -42,13 +42,13 @@ export interface IQueryEditorStateChange {
|
||||
connectingChange?: boolean;
|
||||
}
|
||||
|
||||
export class QueryEditorState {
|
||||
export class QueryEditorState extends Disposable {
|
||||
private _connected = false;
|
||||
private _resultsVisible = false;
|
||||
private _executing = false;
|
||||
private _connecting = false;
|
||||
|
||||
private _onChange = new Emitter<IQueryEditorStateChange>();
|
||||
private _onChange = this._register(new Emitter<IQueryEditorStateChange>());
|
||||
public onChange = this._onChange.event;
|
||||
|
||||
public set connected(val: boolean) {
|
||||
@@ -105,7 +105,7 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
|
||||
public static ID: string = 'workbench.editorinputs.queryInput';
|
||||
public static SCHEMA: string = 'sql';
|
||||
|
||||
private _state = new QueryEditorState();
|
||||
private _state = this._register(new QueryEditorState());
|
||||
public get state(): QueryEditorState { return this._state; }
|
||||
|
||||
private _updateSelection: Emitter<ISelectionData>;
|
||||
@@ -122,16 +122,18 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
|
||||
super();
|
||||
this._updateSelection = new Emitter<ISelectionData>();
|
||||
|
||||
this._toDispose = [];
|
||||
this._register(this._sql);
|
||||
this._register(this._results);
|
||||
|
||||
// re-emit sql editor events through this editor if it exists
|
||||
if (this._sql) {
|
||||
this._toDispose.push(this._sql.onDidChangeDirty(() => this._onDidChangeDirty.fire()));
|
||||
this._register(this._sql.onDidChangeDirty(() => this._onDidChangeDirty.fire()));
|
||||
}
|
||||
|
||||
// Attach to event callbacks
|
||||
if (this._queryModelService) {
|
||||
// Register callbacks for the Actions
|
||||
this._toDispose.push(
|
||||
this._register(
|
||||
this._queryModelService.onRunQueryStart(uri => {
|
||||
if (this.uri === uri) {
|
||||
this.onRunQuery();
|
||||
@@ -139,7 +141,7 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
|
||||
})
|
||||
);
|
||||
|
||||
this._toDispose.push(
|
||||
this._register(
|
||||
this._queryModelService.onRunQueryComplete(uri => {
|
||||
if (this.uri === uri) {
|
||||
this.onQueryComplete();
|
||||
@@ -149,7 +151,7 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
|
||||
}
|
||||
|
||||
if (this._connectionManagementService) {
|
||||
this._toDispose.push(this._connectionManagementService.onDisconnect(result => {
|
||||
this._register(this._connectionManagementService.onDisconnect(result => {
|
||||
if (result.connectionUri === this.uri) {
|
||||
this.onDisconnect();
|
||||
}
|
||||
@@ -164,7 +166,7 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
|
||||
}
|
||||
|
||||
if (this._configurationService) {
|
||||
this._toDispose.push(this._configurationService.onDidChangeConfiguration(e => {
|
||||
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectedKeys.includes('sql.showConnectionInfoInTitle')) {
|
||||
this._onDidChangeLabel.fire();
|
||||
}
|
||||
@@ -307,20 +309,13 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
|
||||
this.state.executing = false;
|
||||
}
|
||||
|
||||
// Clean up functions
|
||||
public dispose(): void {
|
||||
this._sql.dispose();
|
||||
this._results.dispose();
|
||||
this._toDispose = dispose(this._toDispose);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public close(): void {
|
||||
this._queryModelService.disposeQuery(this.uri);
|
||||
this._connectionManagementService.disconnectEditor(this, true);
|
||||
|
||||
this._sql.close();
|
||||
this._results.close();
|
||||
super.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,7 +123,7 @@ export class GridPanel {
|
||||
private runner: QueryRunner;
|
||||
|
||||
private maximizedGrid: GridTable<any>;
|
||||
private _state: GridPanelState;
|
||||
private _state: GridPanelState | undefined;
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@@ -301,6 +301,7 @@ export class GridPanel {
|
||||
for (let i = this.splitView.length - 1; i >= 0; i--) {
|
||||
this.splitView.removeView(i);
|
||||
}
|
||||
this._state = undefined;
|
||||
dispose(this.tables);
|
||||
dispose(this.tableDisposable);
|
||||
this.tableDisposable = [];
|
||||
@@ -346,7 +347,7 @@ export class GridPanel {
|
||||
});
|
||||
}
|
||||
|
||||
public get state(): GridPanelState {
|
||||
public get state() {
|
||||
return this._state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user