mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
Fix some connection listener leaks (#6357)
* Fix some connection listener leaks * More descriptive name and update summary * Dispose some more connections and fix a few spelling errors
This commit is contained in:
@@ -13,6 +13,7 @@ import { NodeType } from 'sql/workbench/parts/objectExplorer/common/nodeType';
|
||||
import { TreeNode } from 'sql/workbench/parts/objectExplorer/common/treeNode';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export interface IExpandableTree extends ITree {
|
||||
// {{SQL CARBON EDIT }} - add back deleted VS Code tree methods
|
||||
@@ -72,8 +73,11 @@ export class TreeUpdateUtils {
|
||||
} else if (viewKey === 'saved') {
|
||||
treeInput = TreeUpdateUtils.getTreeInput(connectionManagementService, providers);
|
||||
}
|
||||
|
||||
const previousTreeInput: any = tree.getInput();
|
||||
return tree.setInput(treeInput).then(() => {
|
||||
if (previousTreeInput instanceof Disposable) {
|
||||
previousTreeInput.dispose();
|
||||
}
|
||||
// Make sure to expand all folders that where expanded in the previous session
|
||||
if (targetsToExpand) {
|
||||
tree.expandAll(targetsToExpand);
|
||||
@@ -135,6 +139,7 @@ export class TreeUpdateUtils {
|
||||
if (groups && groups.length > 0) {
|
||||
let treeInput = groups[0];
|
||||
treeInput.name = 'root';
|
||||
groups.forEach(cpg => cpg.dispose());
|
||||
return treeInput;
|
||||
}
|
||||
// Should never get to this case.
|
||||
|
||||
@@ -117,22 +117,22 @@ export class ConnectionController implements IConnectionComponentController {
|
||||
this._connectionWidget.createConnectionWidget(container);
|
||||
}
|
||||
|
||||
private getServerGroupHelper(group: ConnectionProfileGroup, groupNames: IConnectionProfileGroup[]): void {
|
||||
private flattenGroups(group: ConnectionProfileGroup, allGroups: IConnectionProfileGroup[]): void {
|
||||
if (group) {
|
||||
if (group.fullName !== '') {
|
||||
groupNames.push(group);
|
||||
allGroups.push(group);
|
||||
}
|
||||
if (group.hasChildren()) {
|
||||
group.children.forEach((child) => this.getServerGroupHelper(child, groupNames));
|
||||
group.children.forEach((child) => this.flattenGroups(child, allGroups));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getAllServerGroups(providers?: string[]): IConnectionProfileGroup[] {
|
||||
let connectionGroupRoot = this._connectionManagementService.getConnectionGroups(providers);
|
||||
let connectionGroupNames: IConnectionProfileGroup[] = [];
|
||||
let allGroups: IConnectionProfileGroup[] = [];
|
||||
if (connectionGroupRoot && connectionGroupRoot.length > 0) {
|
||||
this.getServerGroupHelper(connectionGroupRoot[0], connectionGroupNames);
|
||||
this.flattenGroups(connectionGroupRoot[0], allGroups);
|
||||
}
|
||||
let defaultGroupId: string;
|
||||
if (connectionGroupRoot && connectionGroupRoot.length > 0 && ConnectionProfileGroup.isRoot(connectionGroupRoot[0].name)) {
|
||||
@@ -140,9 +140,10 @@ export class ConnectionController implements IConnectionComponentController {
|
||||
} else {
|
||||
defaultGroupId = Utils.defaultGroupId;
|
||||
}
|
||||
connectionGroupNames.push(Object.assign({}, this._connectionWidget.DefaultServerGroup, { id: defaultGroupId }));
|
||||
connectionGroupNames.push(this._connectionWidget.NoneServerGroup);
|
||||
return connectionGroupNames;
|
||||
allGroups.push(Object.assign({}, this._connectionWidget.DefaultServerGroup, { id: defaultGroupId }));
|
||||
allGroups.push(this._connectionWidget.NoneServerGroup);
|
||||
connectionGroupRoot.forEach(cpg => cpg.dispose());
|
||||
return allGroups;
|
||||
}
|
||||
|
||||
public initDialog(providers: string[], connectionInfo: IConnectionProfile): void {
|
||||
|
||||
@@ -316,8 +316,11 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
}
|
||||
}
|
||||
this._model.providerName = this._currentProviderType;
|
||||
|
||||
const previousModel = this._model;
|
||||
this._model = new ConnectionProfile(this._capabilitiesService, this._model);
|
||||
if (previousModel) {
|
||||
previousModel.dispose();
|
||||
}
|
||||
if (this._inputModel && this._inputModel.options) {
|
||||
this.uiController.showUiComponent(input.container,
|
||||
this._inputModel.options.authTypeChanged);
|
||||
@@ -333,9 +336,12 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
|
||||
private handleFillInConnectionInputs(connectionInfo: IConnectionProfile): void {
|
||||
this._connectionManagementService.addSavedPassword(connectionInfo).then(connectionWithPassword => {
|
||||
let model = this.createModel(connectionWithPassword);
|
||||
this._model = model;
|
||||
this.uiController.fillInConnectionInputs(model);
|
||||
if (this._model) {
|
||||
this._model.dispose();
|
||||
}
|
||||
this._model = this.createModel(connectionWithPassword);
|
||||
|
||||
this.uiController.fillInConnectionInputs(this._model);
|
||||
});
|
||||
this._connectionDialog.updateProvider(this._providerNameToDisplayNameMap[connectionInfo.providerName]);
|
||||
}
|
||||
@@ -349,6 +355,9 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
}
|
||||
|
||||
private updateModelServerCapabilities(model: IConnectionProfile) {
|
||||
if (this._model) {
|
||||
this._model.dispose();
|
||||
}
|
||||
this._model = this.createModel(model);
|
||||
if (this._model.providerName) {
|
||||
this._currentProviderType = this._model.providerName;
|
||||
@@ -452,8 +461,10 @@ export class ConnectionDialogService implements IConnectionDialogService {
|
||||
this._connectionDialog.updateProvider(this._providerNameToDisplayNameMap[this._currentProviderType]);
|
||||
|
||||
return new Promise<void>(() => {
|
||||
this._connectionDialog.open(this._connectionManagementService.getRecentConnections(params.providers).length > 0);
|
||||
const recentConnections: ConnectionProfile[] = this._connectionManagementService.getRecentConnections(params.providers);
|
||||
this._connectionDialog.open(recentConnections.length > 0);
|
||||
this.uiController.focusOnOpen();
|
||||
recentConnections.forEach(conn => conn.dispose());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -321,10 +321,14 @@ export class ConnectionDialogWidget extends Modal {
|
||||
const actionProvider = this._instantiationService.createInstance(RecentConnectionActionsProvider);
|
||||
const controller = new RecentConnectionTreeController(leftClick, actionProvider, this._connectionManagementService, this._contextMenuService);
|
||||
actionProvider.onRecentConnectionRemoved(() => {
|
||||
this.open(this._connectionManagementService.getRecentConnections().length > 0);
|
||||
const recentConnections: ConnectionProfile[] = this._connectionManagementService.getRecentConnections();
|
||||
this.open(recentConnections.length > 0);
|
||||
recentConnections.forEach(conn => conn.dispose());
|
||||
});
|
||||
controller.onRecentConnectionRemoved(() => {
|
||||
this.open(this._connectionManagementService.getRecentConnections().length > 0);
|
||||
const recentConnections: ConnectionProfile[] = this._connectionManagementService.getRecentConnections();
|
||||
this.open(recentConnections.length > 0);
|
||||
recentConnections.forEach(conn => conn.dispose());
|
||||
});
|
||||
this._recentConnectionTree = TreeCreationUtils.createConnectionTree(treeContainer, this._instantiationService, controller);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user