summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-03-04 13:57:49 +0100
committerAndrej Mihajlov <and@mullvad.net>2020-03-04 15:09:53 +0100
commitde391ec4dbc90a7e8afa38304b0a5be5105050b4 (patch)
tree167297751dfc457f89215351c921c3af8f214e72 /gui/src
parentca1700dca81ae4599949faab185163dec9b99e34 (diff)
downloadmullvadvpn-de391ec4dbc90a7e8afa38304b0a5be5105050b4.tar.xz
mullvadvpn-de391ec4dbc90a7e8afa38304b0a5be5105050b4.zip
Workaround the exception thrown when accessing BrowserWindow.webContents on already destroyed window
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/window-controller.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/gui/src/main/window-controller.ts b/gui/src/main/window-controller.ts
index 9fb00becf5..69457a63fa 100644
--- a/gui/src/main/window-controller.ts
+++ b/gui/src/main/window-controller.ts
@@ -133,6 +133,7 @@ class AttachedToTrayWindowPositioning implements IWindowPositioning {
export default class WindowController {
private width: number;
private height: number;
+ private webContentsValue: WebContents;
private windowPositioning: IWindowPositioning;
private isWindowReady = false;
@@ -141,13 +142,14 @@ export default class WindowController {
}
get webContents(): WebContents {
- return this.windowValue.webContents;
+ return this.webContentsValue;
}
constructor(private windowValue: BrowserWindow, tray: Tray) {
const [width, height] = windowValue.getSize();
this.width = width;
this.height = height;
+ this.webContentsValue = windowValue.webContents;
this.windowPositioning =
process.platform === 'linux'
? new StandaloneWindowPositioning()
@@ -184,7 +186,7 @@ export default class WindowController {
// Electron uses the `any` type.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
public send(event: string, ...data: any[]): void {
- this.windowValue.webContents.send(event, ...data);
+ this.webContentsValue.send(event, ...data);
}
private showImmediately() {
@@ -205,7 +207,7 @@ export default class WindowController {
private notifyUpdateWindowShape() {
const shapeParameters = this.windowPositioning.getWindowShapeParameters(this.windowValue);
- IpcMainEventChannel.windowShape.notify(this.windowValue.webContents, shapeParameters);
+ IpcMainEventChannel.windowShape.notify(this.webContentsValue, shapeParameters);
}
// Installs display event handlers to update the window position on any changes in the display or