mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-05-11 00:02:38 +02:00
fix browser cleanup
This commit is contained in:
parent
0bb58e55ac
commit
37c1627d79
2 changed files with 19 additions and 6 deletions
|
|
@ -113,7 +113,9 @@ export class BrowserViewManager extends EventEmitter {
|
||||||
|
|
||||||
attach(window: BrowserWindow): void {
|
attach(window: BrowserWindow): void {
|
||||||
this.cleanupWindowListeners?.();
|
this.cleanupWindowListeners?.();
|
||||||
|
this.cleanupWindowListeners = null;
|
||||||
this.window = window;
|
this.window = window;
|
||||||
|
const hostWebContents = window.webContents;
|
||||||
|
|
||||||
const resetForHostWindowNavigation = () => {
|
const resetForHostWindowNavigation = () => {
|
||||||
// Renderer refreshes do not run React unmount cleanup reliably, so the
|
// Renderer refreshes do not run React unmount cleanup reliably, so the
|
||||||
|
|
@ -132,10 +134,16 @@ export class BrowserViewManager extends EventEmitter {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClosed = () => {
|
const handleClosed = () => {
|
||||||
this.cleanupWindowListeners?.();
|
if (this.window !== window) return;
|
||||||
|
|
||||||
|
const tabs = [...this.tabs.values()];
|
||||||
this.cleanupWindowListeners = null;
|
this.cleanupWindowListeners = null;
|
||||||
this.window = null;
|
this.window = null;
|
||||||
this.browserSession = null;
|
this.browserSession = null;
|
||||||
|
this.bounds = { x: 0, y: 0, width: 0, height: 0 };
|
||||||
|
for (const tab of tabs) {
|
||||||
|
this.destroyTab(tab);
|
||||||
|
}
|
||||||
this.tabs.clear();
|
this.tabs.clear();
|
||||||
this.tabOrder = [];
|
this.tabOrder = [];
|
||||||
this.activeTabId = null;
|
this.activeTabId = null;
|
||||||
|
|
@ -144,14 +152,18 @@ export class BrowserViewManager extends EventEmitter {
|
||||||
this.snapshotCache.clear();
|
this.snapshotCache.clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
window.webContents.on('did-start-loading', handleDidStartLoading);
|
hostWebContents.on('did-start-loading', handleDidStartLoading);
|
||||||
window.webContents.on('render-process-gone', handleRenderProcessGone);
|
hostWebContents.on('render-process-gone', handleRenderProcessGone);
|
||||||
window.on('closed', handleClosed);
|
window.on('closed', handleClosed);
|
||||||
|
|
||||||
this.cleanupWindowListeners = () => {
|
this.cleanupWindowListeners = () => {
|
||||||
window.webContents.removeListener('did-start-loading', handleDidStartLoading);
|
if (!hostWebContents.isDestroyed()) {
|
||||||
window.webContents.removeListener('render-process-gone', handleRenderProcessGone);
|
hostWebContents.removeListener('did-start-loading', handleDidStartLoading);
|
||||||
window.removeListener('closed', handleClosed);
|
hostWebContents.removeListener('render-process-gone', handleRenderProcessGone);
|
||||||
|
}
|
||||||
|
if (!window.isDestroyed()) {
|
||||||
|
window.removeListener('closed', handleClosed);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ if (started) app.quit();
|
||||||
// Single-instance lock: route a second launch (e.g. clicking a rowboat:// link)
|
// Single-instance lock: route a second launch (e.g. clicking a rowboat:// link)
|
||||||
// back into the existing process via the 'second-instance' event.
|
// back into the existing process via the 'second-instance' event.
|
||||||
if (!app.requestSingleInstanceLock()) {
|
if (!app.requestSingleInstanceLock()) {
|
||||||
|
console.error('[Main] Another Rowboat instance is already running; exiting this process.');
|
||||||
app.quit();
|
app.quit();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue