Avoid touch an Environemnt after it gets destroyed

This commit is contained in:
Cheng Zhao 2017-03-02 16:50:15 +09:00
parent 29278e500b
commit 24574f7299
3 changed files with 11 additions and 0 deletions

View file

@ -118,6 +118,13 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
}
}
void AtomBindings::EnvironmentDestroyed(node::Environment* env) {
auto it = std::find(pending_next_ticks_.begin(), pending_next_ticks_.end(),
env);
if (it != pending_next_ticks_.end())
pending_next_ticks_.erase(it);
}
void AtomBindings::ActivateUVLoop(v8::Isolate* isolate) {
node::Environment* env = node::Environment::GetCurrent(isolate);
if (std::find(pending_next_ticks_.begin(), pending_next_ticks_.end(), env) !=

View file

@ -27,6 +27,9 @@ class AtomBindings {
// load native code from Electron instead.
void BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process);
// Should be called when a node::Environment has been destroyed.
void EnvironmentDestroyed(node::Environment* env);
static void Log(const base::string16& message);
static void Crash();

View file

@ -384,6 +384,7 @@ void AtomRendererClient::WillReleaseScriptContext(
// Destroy the node environment.
node::FreeEnvironment(env);
atom_bindings_->EnvironmentDestroyed(env);
}
bool AtomRendererClient::ShouldFork(blink::WebLocalFrame* frame,