fix: potential "Object has been destroyed" error in BrowserWindow.getFocusedWindow (#35520)

This commit is contained in:
Milan Burda
2022-09-12 23:46:05 +02:00
committed by GitHub
parent c14f52aeb7
commit b3a744db8a

View File

@@ -72,9 +72,8 @@ BrowserWindow.getAllWindows = () => {
BrowserWindow.getFocusedWindow = () => {
for (const window of BrowserWindow.getAllWindows()) {
const hasWC = window.webContents && !window.webContents.isDestroyed();
if (!window.isDestroyed() && hasWC) {
if (window.isFocused() || window.isDevToolsFocused()) return window;
if (!window.isDestroyed() && window.webContents && !window.webContents.isDestroyed()) {
if (window.isFocused() || window.webContents.isDevToolsFocused()) return window;
}
}
return null;