fix: dangling raw_ptr in ElectronBrowserMainParts dtor (#39539)

* fix: dangling raw_ptr in ElectronBrowserMainParts dtor

* fixup! fix: dangling raw_ptr in ElectronBrowserMainParts dtor

Browser::WhenReady() holds a reference to JsEnv isolate so must come after
This commit is contained in:
Charles Kerr 2023-08-21 03:29:25 -05:00 committed by GitHub
parent 09190085c0
commit 3a91d1f1e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View file

@ -204,11 +204,11 @@ ElectronBrowserMainParts* ElectronBrowserMainParts::self_ = nullptr;
ElectronBrowserMainParts::ElectronBrowserMainParts()
: fake_browser_process_(std::make_unique<BrowserProcessImpl>()),
browser_(std::make_unique<Browser>()),
node_bindings_(
NodeBindings::Create(NodeBindings::BrowserEnvironment::kBrowser)),
electron_bindings_(
std::make_unique<ElectronBindings>(node_bindings_->uv_loop())) {
node_bindings_{
NodeBindings::Create(NodeBindings::BrowserEnvironment::kBrowser)},
electron_bindings_{
std::make_unique<ElectronBindings>(node_bindings_->uv_loop())},
browser_{std::make_unique<Browser>()} {
DCHECK(!self_) << "Cannot have two ElectronBrowserMainParts";
self_ = this;
}

View file

@ -157,11 +157,20 @@ class ElectronBrowserMainParts : public content::BrowserMainParts {
// Before then, we just exit() without any intermediate steps.
absl::optional<int> exit_code_;
std::unique_ptr<JavascriptEnvironment> js_env_;
std::unique_ptr<Browser> browser_;
std::unique_ptr<NodeBindings> node_bindings_;
// depends-on: node_bindings_
std::unique_ptr<ElectronBindings> electron_bindings_;
// depends-on: node_bindings_
std::unique_ptr<JavascriptEnvironment> js_env_;
// depends-on: js_env_'s isolate
std::unique_ptr<NodeEnvironment> node_env_;
// depends-on: js_env_'s isolate
std::unique_ptr<Browser> browser_;
std::unique_ptr<IconManager> icon_manager_;
std::unique_ptr<base::FieldTrialList> field_trial_list_;