Defend against destroyed window when updating zoom factor
This commit is contained in:
parent
03ec561891
commit
9e856e19a0
1 changed files with 9 additions and 3 deletions
12
main.js
12
main.js
|
@ -320,14 +320,20 @@ function handleCommonWindowEvents(window) {
|
||||||
// Works only for mainWindow because it has `enablePreferredSizeMode`
|
// Works only for mainWindow because it has `enablePreferredSizeMode`
|
||||||
let lastZoomFactor = window.webContents.getZoomFactor();
|
let lastZoomFactor = window.webContents.getZoomFactor();
|
||||||
const onZoomChanged = () => {
|
const onZoomChanged = () => {
|
||||||
|
if (
|
||||||
|
window.isDestroyed() ||
|
||||||
|
!window.webContents ||
|
||||||
|
window.webContents.isDestroyed()
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const zoomFactor = window.webContents.getZoomFactor();
|
const zoomFactor = window.webContents.getZoomFactor();
|
||||||
if (lastZoomFactor === zoomFactor) {
|
if (lastZoomFactor === zoomFactor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.webContents) {
|
window.webContents.send('callbacks:call:persistZoomFactor', [zoomFactor]);
|
||||||
window.webContents.send('callbacks:call:persistZoomFactor', [zoomFactor]);
|
|
||||||
}
|
|
||||||
|
|
||||||
lastZoomFactor = zoomFactor;
|
lastZoomFactor = zoomFactor;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue