Main+Renderer: Enforce synchronous messages on `setBounds` channel
This should fix an issue where, when closing the app, an error window would very occasionally pop up declaring that 'getNormalBounds' was called on an undefined variable.
This commit is contained in:
parent
65df233e8a
commit
0551ce44f2
|
@ -294,33 +294,18 @@ function runApp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save closing window bounds & maximized status
|
// Save closing window bounds & maximized status
|
||||||
ipcMain.on('setBounds', (_e, data) => {
|
ipcMain.on('setBounds', (event) => {
|
||||||
const value = {
|
const value = {
|
||||||
...mainWindow.getNormalBounds(),
|
...mainWindow.getNormalBounds(),
|
||||||
maximized: mainWindow.isMaximized()
|
maximized: mainWindow.isMaximized()
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsDb.findOne({
|
settingsDb.update(
|
||||||
_id: 'bounds'
|
{ _id: 'bounds' },
|
||||||
}, function (err, doc) {
|
{ _id: 'bounds', value },
|
||||||
if (err) {
|
{ upsert: true },
|
||||||
return
|
() => { event.returnValue = 0 }
|
||||||
}
|
)
|
||||||
if (doc !== null) {
|
|
||||||
settingsDb.update({
|
|
||||||
_id: 'bounds'
|
|
||||||
}, {
|
|
||||||
$set: {
|
|
||||||
value
|
|
||||||
}
|
|
||||||
}, {})
|
|
||||||
} else {
|
|
||||||
settingsDb.insert({
|
|
||||||
_id: 'bounds',
|
|
||||||
value
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('appReady', () => {
|
ipcMain.on('appReady', () => {
|
||||||
|
|
|
@ -403,8 +403,8 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
setBoundsOnClose: function () {
|
setBoundsOnClose: function () {
|
||||||
window.onbeforeunload = (e) => {
|
window.onbeforeunload = () => {
|
||||||
ipcRenderer.send('setBounds')
|
ipcRenderer.sendSync('setBounds')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue