Add null guards
This commit is contained in:
parent
08b203fed1
commit
cdf33ff3dc
1 changed files with 4 additions and 4 deletions
|
@ -15,16 +15,15 @@ node::Environment* AtomIsolatedWorld::env_ = nullptr;
|
||||||
AtomIsolatedWorld::AtomIsolatedWorld(NodeBindings* node_bindings) :
|
AtomIsolatedWorld::AtomIsolatedWorld(NodeBindings* node_bindings) :
|
||||||
v8::Extension("AtomIsolatedWorld", "native function SetupNode();") {
|
v8::Extension("AtomIsolatedWorld", "native function SetupNode();") {
|
||||||
node_bindings_ = node_bindings;
|
node_bindings_ = node_bindings;
|
||||||
env_ = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomIsolatedWorld::~AtomIsolatedWorld() {
|
AtomIsolatedWorld::~AtomIsolatedWorld() {
|
||||||
node_bindings_ = nullptr;
|
node_bindings_ = nullptr;
|
||||||
env_ = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node::Environment* AtomIsolatedWorld::CreateEnvironment(
|
node::Environment* AtomIsolatedWorld::CreateEnvironment(
|
||||||
content::RenderFrame* frame) {
|
content::RenderFrame* frame) {
|
||||||
|
env_ = nullptr;
|
||||||
blink::WebScriptSource source("SetupNode()");
|
blink::WebScriptSource source("SetupNode()");
|
||||||
frame->GetWebFrame()->executeScriptInIsolatedWorld(
|
frame->GetWebFrame()->executeScriptInIsolatedWorld(
|
||||||
1,
|
1,
|
||||||
|
@ -46,8 +45,9 @@ v8::Local<v8::FunctionTemplate> AtomIsolatedWorld::GetNativeFunctionTemplate(
|
||||||
// static
|
// static
|
||||||
void AtomIsolatedWorld::SetupNode(
|
void AtomIsolatedWorld::SetupNode(
|
||||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
env_ = node_bindings_->CreateEnvironment(
|
if (node_bindings_ != nullptr)
|
||||||
args.GetIsolate()->GetCurrentContext());
|
env_ = node_bindings_->CreateEnvironment(
|
||||||
|
args.GetIsolate()->GetCurrentContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
Loading…
Reference in a new issue