Skip to content

Commit

Permalink
fix: dangling raw_ptr in ElectronBrowserMainParts dtor (electron#39539)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ckerr authored and win32ss committed Sep 24, 2023
1 parent 9df7aaa commit 80a6c8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 5 additions & 5 deletions shell/browser/electron_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
13 changes: 11 additions & 2 deletions shell/browser/electron_browser_main_parts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down

0 comments on commit 80a6c8a

Please sign in to comment.