From 42acbec1c860a312e372e3c59e276b5e50f70c26 Mon Sep 17 00:00:00 2001 From: "trop[bot]" Date: Thu, 24 Jan 2019 14:56:11 +0100 Subject: [PATCH] fix: prevent double-destroy of window (#16512) --- atom/browser/api/atom_api_browser_window.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_browser_window.cc b/atom/browser/api/atom_api_browser_window.cc index 1b0ed8d2950d..cab94da8a910 100644 --- a/atom/browser/api/atom_api_browser_window.cc +++ b/atom/browser/api/atom_api_browser_window.cc @@ -183,7 +183,14 @@ bool BrowserWindow::OnMessageReceived(const IPC::Message& message, } void BrowserWindow::OnCloseContents() { - DCHECK(web_contents()); + // On some machines it may happen that the window gets destroyed for twice, + // checking web_contents() can effectively guard against that. + // https://github.com/electron/electron/issues/16202. + // + // TODO(zcbenz): We should find out the root cause and improve the closing + // procedure of BrowserWindow. + if (!web_contents()) + return; // Close all child windows before closing current window. v8::Locker locker(isolate());