Skip to content

Commit

Permalink
fix: ensure browser context is destroyed after webContents
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak1556 committed Nov 26, 2018
1 parent 527148f commit 830c57b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions atom/browser/common_web_contents_delegate.cc
Expand Up @@ -194,8 +194,17 @@ void CommonWebContentsDelegate::SetOwnerWindow(

void CommonWebContentsDelegate::ResetManagedWebContents(bool async) {
if (async) {
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
web_contents_.release());
// Browser context should be destroyed only after the WebContents,
// this is guaranteed in the sync mode by the order of declaration,
// in the async version we maintain a reference until the WebContents
// is destroyed.
base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
FROM_HERE,
base::BindOnce([](scoped_refptr<AtomBrowserContext> browser_context,
std::unique_ptr<brightray::InspectableWebContents>
web_contents) { web_contents.reset(); },
base::RetainedRef(browser_context_),
std::move(web_contents_)));
} else {
web_contents_.reset();
}
Expand Down

0 comments on commit 830c57b

Please sign in to comment.