Skip to content

Commit

Permalink
fix: crash when beforeunload prevented
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Feb 9, 2023
1 parent 478ce96 commit 3dac168
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions shell/browser/api/electron_api_browser_view.cc
Expand Up @@ -119,6 +119,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
}

BrowserView::~BrowserView() {
LOG(INFO) << "BrowserView::~BrowserView()";
if (web_contents()) { // destroy() called without closing WebContents
web_contents()->RemoveObserver(this);
web_contents()->Destroy();
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/api/electron_api_browser_window.cc
Expand Up @@ -112,7 +112,6 @@ BrowserWindow::~BrowserWindow() {
api_web_contents_->RemoveObserver(this);
// Destroy the WebContents.
OnCloseContents();
api_web_contents_->Destroy();
}
}

Expand Down Expand Up @@ -140,6 +139,7 @@ void BrowserWindow::WebContentsDestroyed() {

void BrowserWindow::OnCloseContents() {
BaseWindow::ResetBrowserViews();
api_web_contents_->Destroy();
}

void BrowserWindow::OnRendererResponsive(content::RenderProcessHost*) {
Expand Down
2 changes: 0 additions & 2 deletions shell/browser/api/electron_api_web_contents.cc
Expand Up @@ -1221,8 +1221,6 @@ void WebContents::CloseContents(content::WebContents* source) {

for (ExtendedWebContentsObserver& observer : observers_)
observer.OnCloseContents();

Destroy();
}

void WebContents::ActivateContents(content::WebContents* source) {
Expand Down

0 comments on commit 3dac168

Please sign in to comment.