From ec4275ca13db5985ab9344926ce403c6a36ab608 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 17:34:21 +0800 Subject: [PATCH] Make sure window is closed before WebContents is destroyed. Otherwise we would get "RawChannel fatal error". --- atom/browser/native_window.cc | 7 ------- atom/browser/native_window_mac.mm | 1 + atom/browser/native_window_views.cc | 1 + 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 4be4ac694124..5481bfa1d67c 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -104,10 +104,6 @@ NativeWindow::NativeWindow(content::WebContents* web_contents, } NativeWindow::~NativeWindow() { - // Make sure we have the OnRenderViewDeleted message sent even when the window - // is destroyed directly. - DestroyWebContents(); - // It's possible that the windows gets destroyed before it's closed, in that // case we need to ensure the OnWindowClosed message is still notified. NotifyWindowClosed(); @@ -453,9 +449,6 @@ void NativeWindow::MoveContents(content::WebContents* source, } void NativeWindow::CloseContents(content::WebContents* source) { - // Destroy the WebContents before we close the window. - DestroyWebContents(); - // When the web contents is gone, close the window immediately, but the // memory will not be freed until you call delete. // In this way, it would be safe to manage windows via smart pointers. If you diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index e16aabdc93a5..804595edbcfc 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -241,6 +241,7 @@ void NativeWindowMac::Close() { void NativeWindowMac::CloseImmediately() { [window_ close]; + window_.reset(); } void NativeWindowMac::Move(const gfx::Rect& pos) { diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 4c99a56389fc..89665c68d56a 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -137,6 +137,7 @@ void NativeWindowViews::Close() { void NativeWindowViews::CloseImmediately() { window_->CloseNow(); + window_.reset(); } void NativeWindowViews::Move(const gfx::Rect& bounds) {