fix: getting focused window with destroyed webContents (#33404)
* fix: getting focused window with destroyed webContents * fix: add extra safeguards
This commit is contained in:
		
					parent
					
						
							
								8ea0631b82
							
						
					
				
			
			
				commit
				
					
						d1ea62c3e8
					
				
			
		
					 2 changed files with 23 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -72,7 +72,10 @@ BrowserWindow.getAllWindows = () => {
 | 
			
		|||
 | 
			
		||||
BrowserWindow.getFocusedWindow = () => {
 | 
			
		||||
  for (const window of BrowserWindow.getAllWindows()) {
 | 
			
		||||
    if (window.isFocused() || window.isDevToolsFocused()) return window;
 | 
			
		||||
    const hasWC = window.webContents && !window.webContents.isDestroyed();
 | 
			
		||||
    if (!window.isDestroyed() && hasWC) {
 | 
			
		||||
      if (window.isFocused() || window.isDevToolsFocused()) return window;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return null;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue