From 61d8445f212a00ac46506f39f2b97b57b0e74f4c Mon Sep 17 00:00:00 2001 From: sawka Date: Thu, 5 Mar 2026 11:04:18 -0800 Subject: [PATCH 1/3] fix bug w/ save session as.... --- emain/emain-ipc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emain/emain-ipc.ts b/emain/emain-ipc.ts index 72498f15c1..e9457a2256 100644 --- a/emain/emain-ipc.ts +++ b/emain/emain-ipc.ts @@ -477,7 +477,7 @@ export function initIpcHandlers() { }); electron.ipcMain.handle("save-text-file", async (event, fileName: string, content: string) => { - const ww = focusedWaveWindow; + const ww = electron.BrowserWindow.fromWebContents(event.sender) ?? focusedWaveWindow; if (ww == null) { return false; } From 185bf6222b41a769ff8534726a51b7615210b297 Mon Sep 17 00:00:00 2001 From: sawka Date: Thu, 5 Mar 2026 11:21:50 -0800 Subject: [PATCH 2/3] fix focusedWaveWindow assignment --- emain/emain-ipc.ts | 20 +++++++++++++++----- emain/emain-window.ts | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/emain/emain-ipc.ts b/emain/emain-ipc.ts index e9457a2256..5b74580163 100644 --- a/emain/emain-ipc.ts +++ b/emain/emain-ipc.ts @@ -24,7 +24,7 @@ import { callWithOriginalXdgCurrentDesktopAsync, unamePlatform } from "./emain-p import { getWaveTabViewByWebContentsId } from "./emain-tabview"; import { handleCtrlShiftState } from "./emain-util"; import { getWaveVersion } from "./emain-wavesrv"; -import { createNewWaveWindow, focusedWaveWindow, getWaveWindowByWebContentsId } from "./emain-window"; +import { createNewWaveWindow, getWaveWindowByWebContentsId } from "./emain-window"; import { ElectronWshClient } from "./emain-wsh"; const electronApp = electron.app; @@ -130,11 +130,16 @@ function getUrlInSession(session: Electron.Session, url: string): Promise { - saveImageFileWithNativeDialog(result.fileName, result.mimeType, result.stream); + saveImageFileWithNativeDialog( + event.sender.hostWebContents, + result.fileName, + result.mimeType, + result.stream + ); }) .catch((e) => { console.log("error getting image", e); @@ -477,7 +487,7 @@ export function initIpcHandlers() { }); electron.ipcMain.handle("save-text-file", async (event, fileName: string, content: string) => { - const ww = electron.BrowserWindow.fromWebContents(event.sender) ?? focusedWaveWindow; + const ww = electron.BrowserWindow.fromWebContents(event.sender); if (ww == null) { return false; } diff --git a/emain/emain-window.ts b/emain/emain-window.ts index 07c0c08a6c..2c34d3a39c 100644 --- a/emain/emain-window.ts +++ b/emain/emain-window.ts @@ -273,6 +273,7 @@ export class WaveBrowserWindow extends BaseWindow { if (getGlobalIsRelaunching()) { return; } + focusedWaveWindow = this; // eslint-disable-line @typescript-eslint/no-this-alias console.log("focus win", this.waveWindowId); fireAndForget(() => ClientService.FocusWindow(this.waveWindowId)); setWasInFg(true); From 160c37adf2b519ef940df7d559f8843050055172 Mon Sep 17 00:00:00 2001 From: sawka Date: Thu, 5 Mar 2026 11:31:12 -0800 Subject: [PATCH 3/3] destroy the readstream properly --- emain/emain-ipc.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/emain/emain-ipc.ts b/emain/emain-ipc.ts index 5b74580163..1d1ec2108a 100644 --- a/emain/emain-ipc.ts +++ b/emain/emain-ipc.ts @@ -141,6 +141,7 @@ function saveImageFileWithNativeDialog( } const ww = electron.BrowserWindow.fromWebContents(sender); if (ww == null) { + readStream.destroy(); return; } const mimeToExtension: { [key: string]: string } = { @@ -169,6 +170,7 @@ function saveImageFileWithNativeDialog( }) .then((file) => { if (file.canceled) { + readStream.destroy(); return; } const writeStream = fs.createWriteStream(file.filePath);