javascript - Object has been destroyed when open secondary/child window in electron js -


in main window, when button clicked, second/child window popped via ipc call. works when open pop window on first time. if closed pop window , reopen again, error:

uncaught exception: error: object has been destroyed @ error (native) @ eventemitter. (/home/xxxx/electron/fin/main.js:36:21) @ emitone (events.js:96:13) @ eventemitter.emit (events.js:188:7) @ eventemitter. (/home/xxxx/electron/fin/node_modules/electron-prebuilt/dist/resources/electron.asar/browser/api/web-contents.js:156:13) @ emittwo (events.js:106:13) @ eventemitter.emit (events.js:191:7)

#main.js on app ready: mainwindow = new browserwindow({width: 800, height: 600})     mainwindow.loadurl(`file://${__dirname}/index.html`)     mainwindow.webcontents.opendevtools()     mainwindow.on('closed', function () {      mainwindow = null   })    let popwindow = new browserwindow({parent: mainwindow, width: 450, height: 450, show: false});   popwindow.loadurl(`file://${__dirname}/app/pop.html`);   popwindow.webcontents.opendevtools();    ipc.on('toggle-popwindow', function(){          popwindow.show();       }); 

and when add hide() in 'closed' method:

popwindow.on('closed', function (event) { popwindow.hide(); }); 

i this:

uncaught exception: error: object has been destroyed 

what problem?

if close browser window destroyed, can't hide or show again after that. since want hide , show again later should add listener close event calls preventdefault() , hides window instead of closing it.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -