From e2bdfee65353185d3849315392b05709f370784e Mon Sep 17 00:00:00 2001 From: makaradam Date: Sat, 2 May 2026 14:36:59 +0200 Subject: [PATCH] fix: scope IPC close-confirm responses to the originating window Both ipcMain.once handlers now check event.sender.id against windowToClose.webContents.id and ignore messages from any other renderer, preventing cross-window response mix-ups if multiple editor windows are ever open simultaneously. --- electron/main.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index 94f0a42..3e0b232 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -295,14 +295,16 @@ function createEditorWindowWrapper() { // Ask renderer to show the custom in-app dialog windowToClose.webContents.send("request-close-confirm"); - ipcMain.once("close-confirm-response", (_, choice: "save" | "discard" | "cancel") => { + ipcMain.once("close-confirm-response", (event, choice: "save" | "discard" | "cancel") => { + if (event.sender.id !== windowToClose?.webContents.id) return; isCloseConfirmInFlight = false; if (!windowToClose || windowToClose.isDestroyed()) return; if (choice === "save") { // Tell renderer to save the project, then close when done windowToClose.webContents.send("request-save-before-close"); - ipcMain.once("save-before-close-done", (_, shouldClose: boolean) => { + ipcMain.once("save-before-close-done", (event, shouldClose: boolean) => { + if (event.sender.id !== windowToClose?.webContents.id) return; if (!shouldClose) return; forceCloseEditorWindow(windowToClose); });