In an electron-react-typescript app I use a button in the mainwindow to open a new window.
If I close this second window clicking on the 'x' on the top-tight corner,
when clicking the button in the mainwindow I get this message:
"Error invoking remote method. TypeError: Object has been destroyed"
.
I found this: Object has been destroyed Exception after reopen BrowserWindow on button click in Electron .
But that suggestion doesn't help me, because clicking on the button in the mainwindow I call this function :
window.api.electronIpcOn('window-A-opened')
which already activate the function in main.ts :
ipcMain.handle("open-type-A-window")
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
mainWindow = null;
WindowTypeA = null;
//WindowTypeA.destroy();
});
I also tried with a windowsList: main.ts
let windowsList = []; const windowDestroy = (win) {
let i = windowsList.indexOf(win);
if (i > -1) {
windowsList.splice(i, 1);
win = null;
}
}
const createWindow = (): void => {
windowsList.push(WindowTypeA);
WindowTypeA.on('closed', function () {
windowDestroy(WindowTypeA);
});
}
but still the same error: "Error invoking remote method. TypeError: Object has been destroyed"
.... So... any suggestions ?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…