From 8785fc52f697ef0992e34259c177546fe480fba7 Mon Sep 17 00:00:00 2001 From: Matt Bierner <12821956+mjbvz@users.noreply.github.com> Date: Thu, 12 Feb 2026 23:39:08 -0800 Subject: [PATCH] Fix leak warning around events --- .../workbench/api/browser/mainThreadPower.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadPower.ts b/src/vs/workbench/api/browser/mainThreadPower.ts index dbd8078aa19..9f7ea9d7d59 100644 --- a/src/vs/workbench/api/browser/mainThreadPower.ts +++ b/src/vs/workbench/api/browser/mainThreadPower.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Disposable, DisposableStore } from '../../../base/common/lifecycle.js'; +import { Disposable } from '../../../base/common/lifecycle.js'; import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js'; import { ExtHostContext, ExtHostPowerShape, MainContext, MainThreadPowerShape, PowerSaveBlockerType, PowerSystemIdleState, PowerThermalState } from '../common/extHost.protocol.js'; import { IPowerService } from '../../services/power/common/powerService.js'; @@ -12,7 +12,6 @@ import { IPowerService } from '../../services/power/common/powerService.js'; export class MainThreadPower extends Disposable implements MainThreadPowerShape { private readonly proxy: ExtHostPowerShape; - private readonly disposables = this._register(new DisposableStore()); constructor( extHostContext: IExtHostContext, @@ -22,14 +21,14 @@ export class MainThreadPower extends Disposable implements MainThreadPowerShape this.proxy = extHostContext.getProxy(ExtHostContext.ExtHostPower); // Forward power events to extension host - this.powerService.onDidSuspend(this.proxy.$onDidSuspend, this.proxy, this.disposables); - this.powerService.onDidResume(this.proxy.$onDidResume, this.proxy, this.disposables); - this.powerService.onDidChangeOnBatteryPower(this.proxy.$onDidChangeOnBatteryPower, this.proxy, this.disposables); - this.powerService.onDidChangeThermalState((state: PowerThermalState) => this.proxy.$onDidChangeThermalState(state), this, this.disposables); - this.powerService.onDidChangeSpeedLimit(this.proxy.$onDidChangeSpeedLimit, this.proxy, this.disposables); - this.powerService.onWillShutdown(this.proxy.$onWillShutdown, this.proxy, this.disposables); - this.powerService.onDidLockScreen(this.proxy.$onDidLockScreen, this.proxy, this.disposables); - this.powerService.onDidUnlockScreen(this.proxy.$onDidUnlockScreen, this.proxy, this.disposables); + this._register(this.powerService.onDidSuspend(this.proxy.$onDidSuspend, this.proxy)); + this._register(this.powerService.onDidResume(this.proxy.$onDidResume, this.proxy)); + this._register(this.powerService.onDidChangeOnBatteryPower(this.proxy.$onDidChangeOnBatteryPower, this.proxy)); + this._register(this.powerService.onDidChangeThermalState((state: PowerThermalState) => this.proxy.$onDidChangeThermalState(state), this)); + this._register(this.powerService.onDidChangeSpeedLimit(this.proxy.$onDidChangeSpeedLimit, this.proxy)); + this._register(this.powerService.onWillShutdown(this.proxy.$onWillShutdown, this.proxy)); + this._register(this.powerService.onDidLockScreen(this.proxy.$onDidLockScreen, this.proxy)); + this._register(this.powerService.onDidUnlockScreen(this.proxy.$onDidUnlockScreen, this.proxy)); } async $getSystemIdleState(idleThreshold: number): Promise {