From 3b81312cf7357837302811683a41da72a0fdf003 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 18 May 2018 16:31:43 +0900 Subject: [PATCH] clear pointer when WebContents is closed --- atom/browser/api/atom_api_web_contents_view.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents_view.cc b/atom/browser/api/atom_api_web_contents_view.cc index a96f4a9c8d6c..e0fb14d16d81 100644 --- a/atom/browser/api/atom_api_web_contents_view.cc +++ b/atom/browser/api/atom_api_web_contents_view.cc @@ -63,12 +63,15 @@ WebContentsView::WebContentsView(v8::Isolate* isolate, } WebContentsView::~WebContentsView() { - api_web_contents_->RemoveObserver(this); - api_web_contents_->DestroyWebContents(false /* async */); + if (api_web_contents_) { + api_web_contents_->RemoveObserver(this); + api_web_contents_->DestroyWebContents(false /* async */); + } } void WebContentsView::OnCloseContents() { - // TODO(zcbenz): WebContents is closed, report the event. + api_web_contents_ = nullptr; + web_contents_.Reset(); } // static