Create polished demo videos without editing skills. Mac/Windows/Linux
Hotfix 1.1.17
webadderallf56f39ddb340
diff --git a/electron/main.ts b/electron/main.tsindex 1cdeb575..4bd94d8c 100644--- a/electron/main.ts+++ b/electron/main.ts@@ -134,11 +134,21 @@ function closeEditorWindowBypassingUnsavedPrompt(window: BrowserWindow | null) {return;}- isForceClosing = true;- editorHasUnsavedChanges = false;+ if (isEditorWindow(window)) {+ isForceClosing = true;+ editorHasUnsavedChanges = false;+ }window.close();}+function restoreWindowSafely(window: BrowserWindow | null) {+ if (!window || window.isDestroyed()) {+ return;+ }++ window.restore();+}+// Tray Icons (lazily created after app is ready to avoid accessing Electron APIs too early)let defaultTrayIcon: ReturnType<typeof getTrayIcon> | null = null;let recordingTrayIcon: ReturnType<typeof getTrayIcon> | null = null;@@ -673,29 +683,37 @@ function updateTrayMenu(recording: boolean = false) {}function createEditorWindowWrapper() {- if (mainWindow) {- closeEditorWindowBypassingUnsavedPrompt(mainWindow);- mainWindow = null;+ const previousWindow = mainWindow;+ if (previousWindow && !previousWindow.isDestroyed()) {+ const closingEditorWindow = isEditorWindow(previousWindow);+ closeEditorWindowBypassingUnsavedPrompt(previousWindow);+ if (!closingEditorWindow) {+ isForceClosing = false;+ }+ if (mainWindow === previousWindow) {+ mainWindow = null;+ }}- mainWindow = createEditorWindow();+ const editorWindow = createEditorWindow();+ mainWindow = editorWindow;editorHasUnsavedChanges = false;- mainWindow.on("closed", () => {- if (mainWindow?.isDestroyed()) {+ editorWindow.on("closed", () => {+ if (mainWindow === editorWindow) {mainWindow = null;}isForceClosing = false;editorHasUnsavedChanges = false;});- mainWindow.on("close", (event) => {+ editorWindow.on("close", (event) => {if (isForceClosing || !editorHasUnsavedChanges) {return;}event.preventDefault();- const choice = dialog.showMessageBoxSync(mainWindow!, {+ const choice = dialog.showMessageBoxSync(editorWindow, {type: "warning",buttons: ["Save & Close", "Discard & Close", "Cancel"],defaultId: 0,@@ -706,14 +724,14 @@ function createEditorWindowWrapper() {});if (choice === 0) {- mainWindow!.webContents.send("request-save-before-close");+ editorWindow.webContents.send("request-save-before-close");ipcMain.once("save-before-close-done", (_event, saved: boolean) => {if (saved) {- closeEditorWindowBypassingUnsavedPrompt(mainWindow);+ closeEditorWindowBypassingUnsavedPrompt(editorWindow);}});} else if (choice === 1) {- closeEditorWindowBypassingUnsavedPrompt(mainWindow);+ closeEditorWindowBypassingUnsavedPrompt(editorWindow);}});}@@ -824,7 +842,7 @@ app.whenReady().then(async () => {reassertHudOverlayMouseState();}if (!recording) {- if (mainWindow) mainWindow.restore();+ restoreWindowSafely(mainWindow);}},);diff --git a/electron/windows.ts b/electron/windows.tsindex 0bfbf309..70116941 100644--- a/electron/windows.ts+++ b/electron/windows.ts@@ -576,8 +576,13 @@ function loadPackagedEditorWindow(win: BrowserWindow) {const queryString = new URLSearchParams(query).toString();const indexHtmlPath = path.join(RENDERER_DIST, "index.html");const packagedRendererBaseUrl = getPackagedRendererBaseUrl();+ const webContents = win.webContents;const loadFromFile = () => {+ if (win.isDestroyed()) {+ return;+ }+console.log("[editor-window] load-file", indexHtmlPath);void win.loadFile(indexHtmlPath, { query });};@@ -600,10 +605,14 @@ function loadPackagedEditorWindow(win: BrowserWindow) {}};- const cleanup = () => {+ const detachLoadListeners = () => {clearTimeoutIfNeeded();- win.webContents.removeListener("did-fail-load", handleDidFailLoad);- win.webContents.removeListener("did-finish-load", handleDidFinishLoad);+ if (webContents.isDestroyed()) {+ return;+ }++ webContents.removeListener("did-fail-load", handleDidFailLoad);+ webContents.removeListener("did-finish-load", handleDidFinishLoad);};const fallbackToFile = (reason: string, details?: Record<string, unknown>) => {@@ -612,7 +621,7 @@ function loadPackagedEditorWindow(win: BrowserWindow) {}settled = true;- cleanup();+ detachLoadListeners();console.warn("[editor-window] packaged renderer URL failed, falling back to file", {reason,targetUrl,@@ -640,17 +649,17 @@ function loadPackagedEditorWindow(win: BrowserWindow) {};const handleDidFinishLoad = () => {- if (win.webContents.getURL() !== targetUrl) {+ if (webContents.getURL() !== targetUrl) {return;}settled = true;- cleanup();+ detachLoadListeners();};- win.webContents.on("did-fail-load", handleDidFailLoad);- win.webContents.on("did-finish-load", handleDidFinishLoad);- win.once("closed", cleanup);+ webContents.on("did-fail-load", handleDidFailLoad);+ webContents.on("did-finish-load", handleDidFinishLoad);+ win.once("closed", clearTimeoutIfNeeded);console.log("[editor-window] load-url", targetUrl);void win.loadURL(targetUrl).catch((error) => {diff --git a/package-lock.json b/package-lock.jsonindex a0127ca3..cdef5fb5 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "recordly",- "version": "1.1.15",+ "version": "1.1.17","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "recordly",- "version": "1.1.15",+ "version": "1.1.17","hasInstallScript": true,"dependencies": {"capturekit": "^1.0.13",diff --git a/package.json b/package.jsonindex 2f627e11..b38faa25 100644--- a/package.json+++ b/package.json@@ -12,7 +12,7 @@"url": "https://github.com/webadderall/Recordly/issues"},"private": true,- "version": "1.1.16",+ "version": "1.1.17","type": "module","scripts": {"dev": "vite",diff --git a/release-notes-v1.1.17.md b/release-notes-v1.1.17.mdnew file mode 100644index 00000000..7060acde--- /dev/null+++ b/release-notes-v1.1.17.md@@ -0,0 +1 @@+Windows object destroyed hotfix\ No newline at end of file