From 8b41e78245a33d4d44a626d105ff4f20840caaf4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 26 Mar 2014 09:14:05 +0800 Subject: [PATCH] Fix a possible crash when destroying window. It could happend that the JS BrowserWindow object being double deleted when calling the destroy() method. --- atom/browser/api/atom_api_window.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index d9bd698d93a3..3d765927c52b 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -127,7 +127,9 @@ void Window::Destroy(const v8::FunctionCallbackInfo& args) { UNWRAP_WINDOW_AND_CHECK; base::ProcessHandle handle = self->window_->GetRenderProcessHandle(); - base::MessageLoop::current()->DeleteSoon(FROM_HERE, self); + // Just destroy the NativeWindow object, the api::Window object would be + // deleted in the coming OnWindowClosed event. + self->window_.reset(); // Make sure the renderer process is terminated, it could happen that the // renderer process became a zombie.