fix: crash on parent window close and focur/blur (#46580)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
b234733555
commit
28eb0e6f3d
2 changed files with 14 additions and 2 deletions
|
@ -219,14 +219,14 @@ void BrowserWindow::CloseImmediately() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::Focus() {
|
void BrowserWindow::Focus() {
|
||||||
if (api_web_contents_->IsOffScreen())
|
if (api_web_contents_ && api_web_contents_->IsOffScreen())
|
||||||
FocusOnWebView();
|
FocusOnWebView();
|
||||||
else
|
else
|
||||||
BaseWindow::Focus();
|
BaseWindow::Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::Blur() {
|
void BrowserWindow::Blur() {
|
||||||
if (api_web_contents_->IsOffScreen())
|
if (api_web_contents_ && api_web_contents_->IsOffScreen())
|
||||||
BlurWebView();
|
BlurWebView();
|
||||||
else
|
else
|
||||||
BaseWindow::Blur();
|
BaseWindow::Blur();
|
||||||
|
|
|
@ -4930,6 +4930,18 @@ describe('BrowserWindow module', () => {
|
||||||
expect(w.getChildWindows().length).to.equal(0);
|
expect(w.getChildWindows().length).to.equal(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can handle parent window close with focus or blur events', (done) => {
|
||||||
|
const w = new BrowserWindow({ show: false });
|
||||||
|
const c = new BrowserWindow({ show: false, parent: w });
|
||||||
|
|
||||||
|
c.on('closed', () => {
|
||||||
|
w.focus();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
w.close();
|
||||||
|
});
|
||||||
|
|
||||||
ifit(process.platform === 'darwin')('only shows the intended window when a child with siblings is shown', async () => {
|
ifit(process.platform === 'darwin')('only shows the intended window when a child with siblings is shown', async () => {
|
||||||
const w = new BrowserWindow({ show: false });
|
const w = new BrowserWindow({ show: false });
|
||||||
const childOne = new BrowserWindow({ show: false, parent: w });
|
const childOne = new BrowserWindow({ show: false, parent: w });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue