From 676b1e0bc7f5782183ff9aba0fc4ab2b3caa0f78 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 9 May 2014 09:26:46 +0800 Subject: [PATCH] Fix closing a crashed window, closes #269. --- atom/browser/native_window.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 816888d7..79b024ef 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -307,6 +307,10 @@ void NativeWindow::CloseWebContents() { } content::WebContents* web_contents(GetWebContents()); + if (!web_contents) { + CloseImmediately(); + return; + } // Assume the window is not responding if it doesn't cancel the close and is // not closed in 10s, in this way we can quickly show the unresponsive @@ -322,10 +326,14 @@ void NativeWindow::CloseWebContents() { } content::WebContents* NativeWindow::GetWebContents() const { - return inspectable_web_contents_->GetWebContents(); + if (!inspectable_web_contents_) + return NULL; + return inspectable_web_contents()->GetWebContents(); } content::WebContents* NativeWindow::GetDevToolsWebContents() const { + if (!inspectable_web_contents_) + return NULL; return inspectable_web_contents()->devtools_web_contents(); } -- 2.43.0