diff --git a/src/main/main.ts b/src/main/main.ts index 0b38740d..2569eca2 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -2676,6 +2676,7 @@ function createExportWindow( // Finish setup exportWindow.setMenu(null); exportWindow.once("ready-to-show", parentWindow.show); + let isPreparingExport = false; exportWindow.webContents.on("dom-ready", () => { // Create ports on reload const { port1, port2 } = new MessageChannelMain(); @@ -2719,12 +2720,18 @@ function createExportWindow( }) .then((response) => { if (!response.canceled) { + isPreparingExport = true; exportWindow.destroy(); sendMessage(parentWindow, "prepare-export", { path: response.filePath, options: exportOptions }); } }); } }); + exportWindow.on("closed", () => { + if (!isPreparingExport) { + sendMessage(parentWindow, "cancel-export"); + } + }); exportWindow.on("blur", () => port2.postMessage({ isFocused: false })); exportWindow.on("focus", () => port2.postMessage({ isFocused: true })); port2.postMessage({ supportsAkit: supportsAkit });