Fix JS error on app quit (#377)
This was a rare race condition during app shutdown where a 'wt-' message would be sent from the hidden webtorrent window to the main window after the main window was already closed. Fixes #373
This commit is contained in:
@@ -87,7 +87,7 @@ function init () {
|
|||||||
var oldEmit = ipcMain.emit
|
var oldEmit = ipcMain.emit
|
||||||
ipcMain.emit = function (name, e, ...args) {
|
ipcMain.emit = function (name, e, ...args) {
|
||||||
// Relay messages between the main window and the WebTorrent hidden window
|
// Relay messages between the main window and the WebTorrent hidden window
|
||||||
if (name.startsWith('wt-')) {
|
if (name.startsWith('wt-') && !app.isQuitting) {
|
||||||
if (e.sender.browserWindowOptions.title === 'webtorrent-hidden-window') {
|
if (e.sender.browserWindowOptions.title === 'webtorrent-hidden-window') {
|
||||||
// Send message to main window
|
// Send message to main window
|
||||||
windows.main.send(name, ...args)
|
windows.main.send(name, ...args)
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ function createWebTorrentHiddenWindow () {
|
|||||||
win.hide()
|
win.hide()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
win.once('closed', function () {
|
||||||
|
windows.webtorrent = null
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMainWindow () {
|
function createMainWindow () {
|
||||||
|
|||||||
Reference in New Issue
Block a user