debug: dispose of event subscriptions (#214358)

Refs #214234
This commit is contained in:
Connor Peet 2024-06-05 10:18:13 -07:00 committed by GitHub
parent 7cc8d36ec4
commit 4eb1515a2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 15 deletions

View file

@ -7,6 +7,7 @@ import { asPromise } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Emitter, Event } from 'vs/base/common/event';
import { URI, UriComponents } from 'vs/base/common/uri';
import { Disposable as DisposableCls, toDisposable } from 'vs/base/common/lifecycle';
import { ExtensionIdentifier, IExtensionDescription, IRelaxedExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ISignService } from 'vs/platform/sign/common/sign';
@ -25,7 +26,6 @@ import { Dto } from 'vs/workbench/services/extensions/common/proxyIdentifier';
import type * as vscode from 'vscode';
import { IExtHostConfiguration } from '../common/extHostConfiguration';
import { IExtHostVariableResolverProvider } from './extHostVariableResolverService';
import { toDisposable } from 'vs/base/common/lifecycle';
import { ThemeIcon as ThemeIconUtils } from 'vs/base/common/themables';
import { IExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
import * as Convert from 'vs/workbench/api/common/extHostTypeConverters';
@ -60,7 +60,7 @@ export interface IExtHostDebugService extends ExtHostDebugServiceShape {
asDebugSourceUri(source: vscode.DebugProtocolSource, session?: vscode.DebugSession): vscode.Uri;
}
export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, ExtHostDebugServiceShape {
export abstract class ExtHostDebugServiceBase extends DisposableCls implements IExtHostDebugService, ExtHostDebugServiceShape {
readonly _serviceBrand: undefined;
@ -124,6 +124,8 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
@IExtHostVariableResolverProvider private _variableResolver: IExtHostVariableResolverProvider,
@IExtHostCommands private _commands: IExtHostCommands,
) {
super();
this._configProviderHandleCounter = 0;
this._configProviders = [];
@ -136,25 +138,25 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
this._debugAdapters = new Map();
this._debugAdaptersTrackers = new Map();
this._onDidStartDebugSession = new Emitter<vscode.DebugSession>();
this._onDidTerminateDebugSession = new Emitter<vscode.DebugSession>();
this._onDidChangeActiveDebugSession = new Emitter<vscode.DebugSession | undefined>();
this._onDidReceiveDebugSessionCustomEvent = new Emitter<vscode.DebugSessionCustomEvent>();
this._onDidStartDebugSession = this._register(new Emitter<vscode.DebugSession>());
this._onDidTerminateDebugSession = this._register(new Emitter<vscode.DebugSession>());
this._onDidChangeActiveDebugSession = this._register(new Emitter<vscode.DebugSession | undefined>());
this._onDidReceiveDebugSessionCustomEvent = this._register(new Emitter<vscode.DebugSessionCustomEvent>());
this._debugServiceProxy = extHostRpcService.getProxy(MainContext.MainThreadDebugService);
this._onDidChangeBreakpoints = new Emitter<vscode.BreakpointsChangeEvent>();
this._onDidChangeBreakpoints = this._register(new Emitter<vscode.BreakpointsChangeEvent>());
this._onDidChangeActiveStackItem = new Emitter<vscode.DebugThread | vscode.DebugStackFrame | undefined>();
this._onDidChangeActiveStackItem = this._register(new Emitter<vscode.DebugThread | vscode.DebugStackFrame | undefined>());
this._activeDebugConsole = new ExtHostDebugConsole(this._debugServiceProxy);
this._breakpoints = new Map<string, vscode.Breakpoint>();
this._extensionService.getExtensionRegistry().then((extensionRegistry: ExtensionDescriptionRegistry) => {
extensionRegistry.onDidChange(_ => {
this._register(extensionRegistry.onDidChange(_ => {
this.registerAllDebugTypes(extensionRegistry);
});
}));
this.registerAllDebugTypes(extensionRegistry);
});
}

View file

@ -78,9 +78,9 @@ export class ExtHostDebugService extends ExtHostDebugServiceBase {
if (!this._terminalDisposedListener) {
// React on terminal disposed and check if that is the debug terminal #12956
this._terminalDisposedListener = this._terminalService.onDidCloseTerminal(terminal => {
this._terminalDisposedListener = this._register(this._terminalService.onDidCloseTerminal(terminal => {
this._integratedTerminalInstances.onTerminalClosed(terminal);
});
}));
}
const configProvider = await this._configurationService.getConfigProvider();

View file

@ -10,7 +10,7 @@ import { Action, IAction, IRunEvent, WorkbenchActionExecutedClassification, Work
import * as arrays from 'vs/base/common/arrays';
import { RunOnceScheduler } from 'vs/base/common/async';
import * as errors from 'vs/base/common/errors';
import { DisposableStore, dispose, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { DisposableStore, dispose, IDisposable, markAsSingleton, MutableDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import 'vs/css!./media/debugToolBar';
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
@ -401,7 +401,7 @@ const registerDebugToolBarItem = (id: string, title: string | ICommandActionTitl
}));
};
MenuRegistry.onDidChangeMenu(e => {
markAsSingleton(MenuRegistry.onDidChangeMenu(e => {
// In case the debug toolbar is docked we need to make sure that the docked toolbar has the up to date commands registered #115945
if (e.has(MenuId.DebugToolBar)) {
dispose(debugViewTitleItems);
@ -413,7 +413,7 @@ MenuRegistry.onDidChangeMenu(e => {
}));
}
}
});
}));
const CONTEXT_TOOLBAR_COMMAND_CENTER = ContextKeyExpr.equals('config.debug.toolBarLocation', 'commandCenter');