From 1850947a1727c5b9f3be35c8e3d4f221fe8e1414 Mon Sep 17 00:00:00 2001 From: MathieuG-P <40181755+Zagrios@users.noreply.github.com> Date: Fri, 1 Dec 2023 02:16:31 +0100 Subject: [PATCH] [bugfix] Error when closing oneclick download window while still downloading stop send data after the window is destroyed + unsubscribe observable when the window closes --- src/main/services/ipc.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/services/ipc.service.ts b/src/main/services/ipc.service.ts index 550a32fd..cd1f8f50 100644 --- a/src/main/services/ipc.service.ts +++ b/src/main/services/ipc.service.ts @@ -39,6 +39,7 @@ export class IpcService { } public send(channel: string, window: BrowserWindow, response?: T | Error): void { + if(window.webContents?.isDestroyed()){ return; } window.webContents?.send(channel, response); } @@ -53,6 +54,7 @@ export class IpcService { complete: () => this.send(this.getCompleteChannel(channel), window) }) + window.webContents.once("destroyed", () => sub.unsubscribe()); window.webContents.ipc.once(this.getTearDownChannel(channel), () => sub.unsubscribe()); sub.add(() => {