Skip to content

Commit

Permalink
fix: force child windows to close when main window closes
Browse files Browse the repository at this point in the history
  • Loading branch information
zunderscore committed Mar 8, 2024
1 parent a11e5ba commit 9ebda05
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/backend/app-management/electron/window-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ const { settings } = require("../../common/settings-access");

setupTitlebar();


/**
* The variable inspector window.
*@type {Electron.BrowserWindow}
*/
let variableInspectorWindow = null;

/**
* The stream preview popout window.
* Keeps a global reference of the window object, if you don't, the window will
Expand Down Expand Up @@ -478,6 +485,18 @@ async function createMainWindow() {
global.renderWindow = null;
}
});

mainWindow.on("closed", () => {
if (variableInspectorWindow?.isDestroyed() === false) {
logger.debug("Closing variable inspector window");
variableInspectorWindow.destroy();
}

if (streamPreview?.isDestroyed() === false) {
logger.debug("Closing stream preview window");
streamPreview.destroy();
}
});
}

/**
Expand Down Expand Up @@ -529,12 +548,6 @@ function updateSplashScreenStatus(newStatus) {
splashscreenWindow.webContents.send("update-splash-screen-status", newStatus);
}

/**
* The variable inspector window.
*@type {Electron.BrowserWindow}
*/
let variableInspectorWindow = null;

async function createVariableInspectorWindow() {

if (variableInspectorWindow != null && !variableInspectorWindow.isDestroyed()) {
Expand Down

0 comments on commit 9ebda05

Please sign in to comment.