trigger beforeunload; fix crash when getting webContents after destroy

This commit is contained in:
Jeremy Rose
2022-10-05 17:05:29 -07:00
parent 389fefac8a
commit 997d46f090
2 changed files with 8 additions and 1 deletions

View File

@@ -47,6 +47,10 @@ BrowserWindow.prototype._init = function (this: BWT) {
this._browserViews = [];
this.on('close', () => {
this._browserViews.forEach(b => b.webContents.close({ waitForBeforeUnload: true }));
});
const warn = deprecate.warnOnceMessage('\'scroll-touch-{begin,end,edge}\' are deprecated and will be removed. Please use the WebContents \'input-event\' event instead.');
this.webContents.on('input-event', (_, e) => {
if (e.type === 'gestureScrollBegin') {

View File

@@ -54,7 +54,10 @@ WebContentsView::~WebContentsView() {
}
gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) {
return gin::CreateHandle(isolate, api_web_contents_);
if (api_web_contents_)
return gin::CreateHandle(isolate, api_web_contents_);
else
return gin::Handle<WebContents>();
}
void WebContentsView::SetBackgroundColor(absl::optional<WrappedSkColor> color) {