mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 09:35:38 -05:00
Remove disposable from connection (#22687)
* Remove disposable from connection * Remove from group
This commit is contained in:
@@ -87,9 +87,7 @@ export class ConnectionConfig {
|
||||
// Remove the profile if already set
|
||||
let sameProfileInList = profiles.find(value => {
|
||||
const providerConnectionProfile = ConnectionProfile.createFromStoredProfile(value, this._capabilitiesService);
|
||||
const match = matcher(providerConnectionProfile, connectionProfile);
|
||||
providerConnectionProfile.dispose();
|
||||
return match;
|
||||
return matcher(providerConnectionProfile, connectionProfile);
|
||||
});
|
||||
if (sameProfileInList) {
|
||||
let profileIndex = profiles.findIndex(value => value === sameProfileInList);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
|
||||
export interface INewConnectionProfileGroup {
|
||||
@@ -19,7 +18,7 @@ export interface IConnectionProfileGroup extends INewConnectionProfileGroup {
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export class ConnectionProfileGroup extends Disposable implements IConnectionProfileGroup {
|
||||
export class ConnectionProfileGroup implements IConnectionProfileGroup {
|
||||
|
||||
private _childGroups: ConnectionProfileGroup[] = [];
|
||||
private _childConnections: ConnectionProfile[] = [];
|
||||
@@ -35,7 +34,6 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
public color?: string,
|
||||
public description?: string
|
||||
) {
|
||||
super();
|
||||
this.parentId = parent ? parent.id : undefined;
|
||||
if (ConnectionProfileGroup.isRoot(this.name)) {
|
||||
this.name = '';
|
||||
@@ -146,7 +144,6 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
connections?.forEach((conn) => {
|
||||
this._childConnections = this._childConnections.filter((curConn) => { return curConn.id !== conn.id; });
|
||||
conn.parent = this;
|
||||
this._register(conn);
|
||||
this._childConnections.push(conn);
|
||||
});
|
||||
|
||||
@@ -156,7 +153,6 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
|
||||
groups?.forEach((group) => {
|
||||
this._childGroups = this._childGroups.filter((grp) => { return group.id !== grp.id; });
|
||||
group.parent = this;
|
||||
this._register(group);
|
||||
this._childGroups.push(group);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -181,10 +181,8 @@ export class ConnectionStore {
|
||||
}
|
||||
|
||||
public getProfileWithoutPassword(conn: IConnectionProfile): ConnectionProfile {
|
||||
let savedConn = ConnectionProfile.fromIConnectionProfile(this.capabilitiesService, conn);
|
||||
let newSavedConn = savedConn.withoutPassword();
|
||||
savedConn.dispose();
|
||||
return newSavedConn;
|
||||
const savedConn = ConnectionProfile.fromIConnectionProfile(this.capabilitiesService, conn);
|
||||
return savedConn.withoutPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,9 +227,7 @@ export class ConnectionStore {
|
||||
|
||||
list.unshift(savedProfile);
|
||||
|
||||
const profiles = list.filter(n => n !== undefined).map(c => c.toIConnectionProfile());
|
||||
list.forEach(c => c.dispose());
|
||||
return profiles;
|
||||
return list.filter(n => n !== undefined).map(c => c.toIConnectionProfile());
|
||||
}
|
||||
|
||||
private removeFromConnectionList(conn: IConnectionProfile, list: ConnectionProfile[]): IConnectionProfile[] {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { isString } from 'vs/base/common/types';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
@@ -14,7 +13,7 @@ import { localize } from 'vs/nls';
|
||||
|
||||
type SettableProperty = 'serverName' | 'authenticationType' | 'databaseName' | 'password' | 'connectionName' | 'userName';
|
||||
|
||||
export class ProviderConnectionInfo extends Disposable implements azdata.ConnectionInfo {
|
||||
export class ProviderConnectionInfo implements azdata.ConnectionInfo {
|
||||
|
||||
options: { [name: string]: any } = {};
|
||||
|
||||
@@ -25,7 +24,6 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
protected capabilitiesService: ICapabilitiesService,
|
||||
model: string | azdata.IConnectionProfile | azdata.connection.ConnectionProfile | undefined
|
||||
) {
|
||||
super();
|
||||
// we can't really do a whole lot if we don't have a provider
|
||||
if (model) {
|
||||
this.providerName = isString(model) ? model : 'providerName' in model ? model.providerName : model.providerId;
|
||||
@@ -69,14 +67,6 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
this._providerName = name;
|
||||
}
|
||||
|
||||
public override dispose(): void {
|
||||
// Notes:
|
||||
// 1. It is not recommended to add disposables to this class considering the way we create and use the connection objects,
|
||||
// there are places that the connection objects are not being disposed properly.
|
||||
// 2. Remember to dispose the listeners added to this class.
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public clone(): ProviderConnectionInfo {
|
||||
let instance = new ProviderConnectionInfo(this.capabilitiesService, this.providerName);
|
||||
instance.options = Object.assign({}, this.options);
|
||||
|
||||
Reference in New Issue
Block a user