fix: NodeService order-of-destruction issue (#39783)
* refactor: make ElectronRendererClient::node_bindings_ a const ptr refactor: make ElectronRendererClient::electron_bindings_ a const ptr * fix: order-of-destruction bug in NodeService js_env_ depends on the uv_loop from node_bindings_, but is destroyed after node_bindings_ * chore: revert unintentional commit
This commit is contained in:
parent
ec9c8476fe
commit
a1c44a18e2
2 changed files with 14 additions and 6 deletions
|
@ -20,10 +20,10 @@ namespace electron {
|
||||||
|
|
||||||
NodeService::NodeService(
|
NodeService::NodeService(
|
||||||
mojo::PendingReceiver<node::mojom::NodeService> receiver)
|
mojo::PendingReceiver<node::mojom::NodeService> receiver)
|
||||||
: node_bindings_(
|
: node_bindings_{NodeBindings::Create(
|
||||||
NodeBindings::Create(NodeBindings::BrowserEnvironment::kUtility)),
|
NodeBindings::BrowserEnvironment::kUtility)},
|
||||||
electron_bindings_(
|
electron_bindings_{
|
||||||
std::make_unique<ElectronBindings>(node_bindings_->uv_loop())) {
|
std::make_unique<ElectronBindings>(node_bindings_->uv_loop())} {
|
||||||
if (receiver.is_valid())
|
if (receiver.is_valid())
|
||||||
receiver_.Bind(std::move(receiver));
|
receiver_.Bind(std::move(receiver));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,18 @@ class NodeService : public node::mojom::NodeService {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool node_env_stopped_ = false;
|
bool node_env_stopped_ = false;
|
||||||
|
|
||||||
|
const std::unique_ptr<NodeBindings> node_bindings_;
|
||||||
|
|
||||||
|
// depends-on: node_bindings_'s uv_loop
|
||||||
|
const std::unique_ptr<ElectronBindings> electron_bindings_;
|
||||||
|
|
||||||
|
// depends-on: node_bindings_'s uv_loop
|
||||||
std::unique_ptr<JavascriptEnvironment> js_env_;
|
std::unique_ptr<JavascriptEnvironment> js_env_;
|
||||||
std::unique_ptr<NodeBindings> node_bindings_;
|
|
||||||
std::unique_ptr<ElectronBindings> electron_bindings_;
|
// depends-on: js_env_'s isolate
|
||||||
std::shared_ptr<node::Environment> node_env_;
|
std::shared_ptr<node::Environment> node_env_;
|
||||||
|
|
||||||
mojo::Receiver<node::mojom::NodeService> receiver_{this};
|
mojo::Receiver<node::mojom::NodeService> receiver_{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue