mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-24 23:05:49 +00:00
Hotfix 1.1.17
This commit is contained in:
+32
-14
@@ -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);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
+18
-9
@@ -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) => {
|
||||
|
||||
Generated
+2
-2
@@ -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",
|
||||
|
||||
+1
-1
@@ -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",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Windows object destroyed hotfix
|
||||
Reference in New Issue
Block a user