Skip to content

Commit

Permalink
fix: potential "Object has been destroyed" error in BrowserWindow.get…
Browse files Browse the repository at this point in the history
…FocusedWindow (#35645)

Co-authored-by: Milan Burda <milan.burda@gmail.com>
  • Loading branch information
trop[bot] and miniak committed Sep 13, 2022
1 parent 27dc8d4 commit 90068fa
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/browser/api/browser-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 90068fa

Please sign in to comment.