ignore events on destroyed windows

This commit is contained in:
Eugene Pankov
2019-02-09 22:38:45 +01:00
parent 9cdcc8d8e5
commit 22d3e35723

View File

@@ -182,28 +182,28 @@ export class Window {
}) })
ipcMain.on('window-focus', event => { ipcMain.on('window-focus', event => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.window.focus() this.window.focus()
}) })
ipcMain.on('window-maximize', event => { ipcMain.on('window-maximize', event => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.window.maximize() this.window.maximize()
}) })
ipcMain.on('window-unmaximize', event => { ipcMain.on('window-unmaximize', event => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.window.unmaximize() this.window.unmaximize()
}) })
ipcMain.on('window-toggle-maximize', event => { ipcMain.on('window-toggle-maximize', event => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
if (this.window.isMaximized()) { if (this.window.isMaximized()) {
@@ -214,42 +214,42 @@ export class Window {
}) })
ipcMain.on('window-minimize', event => { ipcMain.on('window-minimize', event => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.window.minimize() this.window.minimize()
}) })
ipcMain.on('window-set-bounds', (event, bounds) => { ipcMain.on('window-set-bounds', (event, bounds) => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.window.setBounds(bounds) this.window.setBounds(bounds)
}) })
ipcMain.on('window-set-always-on-top', (event, flag) => { ipcMain.on('window-set-always-on-top', (event, flag) => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.window.setAlwaysOnTop(flag) this.window.setAlwaysOnTop(flag)
}) })
ipcMain.on('window-set-vibrancy', (event, enabled, type) => { ipcMain.on('window-set-vibrancy', (event, enabled, type) => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.setVibrancy(enabled, type) this.setVibrancy(enabled, type)
}) })
ipcMain.on('window-set-title', (event, title) => { ipcMain.on('window-set-title', (event, title) => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.window.setTitle(title) this.window.setTitle(title)
}) })
ipcMain.on('window-bring-to-front', event => { ipcMain.on('window-bring-to-front', event => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
if (this.window.isMinimized()) { if (this.window.isMinimized()) {
@@ -260,7 +260,7 @@ export class Window {
}) })
ipcMain.on('window-close', event => { ipcMain.on('window-close', event => {
if (event.sender !== this.window.webContents) { if (!this.window || event.sender !== this.window.webContents) {
return return
} }
this.closing = true this.closing = true