Detach from devtools before destroying

Otherwise Electron would crash on exit in Chrome 58.
This commit is contained in:
Cheng Zhao 2017-03-20 12:22:46 -07:00
parent 79a441874e
commit 98c039c880
2 changed files with 11 additions and 4 deletions

View file

@ -235,9 +235,14 @@ InspectableWebContentsImpl::InspectableWebContentsImpl(
}
InspectableWebContentsImpl::~InspectableWebContentsImpl() {
if (devtools_web_contents_)
devtools_web_contents_->Close();
Observe(nullptr);
// Unsubscribe from devtools and Clean up resources.
if (devtools_web_contents_) {
devtools_web_contents_->SetDelegate(nullptr);
// Calling this also unsubscribes the observer, so WebContentsDestroyed
// won't be called again.
WebContentsDestroyed();
}
// Let destructor destroy devtools_web_contents_.
}
InspectableWebContentsView* InspectableWebContentsImpl::GetView() const {
@ -651,6 +656,7 @@ void InspectableWebContentsImpl::RenderFrameHostChanged(
void InspectableWebContentsImpl::WebContentsDestroyed() {
frontend_loaded_ = false;
Observe(nullptr);
Detach();
for (const auto& pair : pending_requests_)
@ -695,6 +701,7 @@ void InspectableWebContentsImpl::HandleKeyboardEvent(
}
void InspectableWebContentsImpl::CloseContents(content::WebContents* source) {
// This is where the devtools closes itself (by clicking the x button).
CloseDevTools();
}

@ -1 +1 @@
Subproject commit 8c3e532385811b5cea80e969c1beb1bf3ffb6777
Subproject commit 791141a820ecf6166a86249701838b57f43777ea