change to render-process-gone

`crashed` is deprecated. 
https://github.com/electron/electron/blob/9-x-y/docs/api/web-contents.md

Note: The previous code shows the error dialog on both the "killed" and "crashed" events. But now it's only "crashed"
This commit is contained in:
steven nguyen 2021-10-21 08:12:48 -05:00 committed by GitHub
parent f5a1adc71b
commit 5238a022e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -236,30 +236,32 @@ module.exports = class AtomWindow extends EventEmitter {
if (result.response === 0) this.browserWindow.destroy();
});
this.browserWindow.webContents.on('crashed', async () => {
if (this.headless) {
console.log('Renderer process crashed, exiting');
this.atomApplication.exit(100);
return;
}
this.browserWindow.webContents.on('render-process-gone', async (event, { reason }) => {
if (reason === "crashed") {
if (this.headless) {
console.log('Renderer process crashed, exiting');
this.atomApplication.exit(100);
return;
}
await this.fileRecoveryService.didCrashWindow(this);
await this.fileRecoveryService.didCrashWindow(this);
const result = await dialog.showMessageBox(this.browserWindow, {
type: 'warning',
buttons: ['Close Window', 'Reload', 'Keep It Open'],
cancelId: 2, // Canceling should be the least destructive action
message: 'The editor has crashed',
detail: 'Please report this issue to https://github.com/atom/atom'
});
const result = await dialog.showMessageBox(this.browserWindow, {
type: 'warning',
buttons: ['Close Window', 'Reload', 'Keep It Open'],
cancelId: 2, // Canceling should be the least destructive action
message: 'The editor has crashed',
detail: 'Please report this issue to https://github.com/atom/atom'
});
switch (result.response) {
case 0:
this.browserWindow.destroy();
break;
case 1:
this.browserWindow.reload();
break;
switch (result.response) {
case 0:
this.browserWindow.destroy();
break;
case 1:
this.browserWindow.reload();
break;
}
}
});