From aeeb2a259f1d28ef6d9a1f89f177c9f230cab888 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 17 May 2018 09:09:45 +0900 Subject: [PATCH] destruct objects in stack order --- atom/browser/atom_browser_main_parts.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 8cccac09931f..6c071a318b5f 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -121,7 +121,10 @@ int AtomBrowserMainParts::GetExitCode() { void AtomBrowserMainParts::RegisterDestructionCallback( base::OnceClosure callback) { - destructors_.insert(destructors_.end(), std::move(callback)); + // The destructors should be called in reversed order, so dependencies between + // JavaScript objects can be correctly resolved. + // For example WebContentsView => WebContents => Session. + destructors_.insert(destructors_.begin(), std::move(callback)); } void AtomBrowserMainParts::PreEarlyInitialization() {