Skip to content

Commit

Permalink
fix: dangling raw_ptr in ElectronBrowserMainParts dtor (#39591)
Browse files Browse the repository at this point in the history
* fix: dangling raw_ptr in ElectronBrowserMainParts dtor

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fixup! fix: dangling raw_ptr in ElectronBrowserMainParts dtor

Browser::WhenReady() holds a reference to JsEnv isolate so must come after

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
  • Loading branch information
trop[bot] and ckerr committed Aug 21, 2023
1 parent cec0e9c commit 0641a85
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 @@ -210,11 +210,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 @@ -165,11 +165,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 0641a85

Please sign in to comment.