From: Cheng Zhao Date: Wed, 8 Jan 2014 02:30:30 +0000 (+0800) Subject: Fix invoking non-exist method when quiting. X-Git-Tag: v0.8.3~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=93d5a2e19503ebb3559d1ec2d5f5d3297c59e8b8;p=electron.git Fix invoking non-exist method when quiting. --- diff --git a/common/node_bindings.cc b/common/node_bindings.cc index a349aef0..317f6795 100644 --- a/common/node_bindings.cc +++ b/common/node_bindings.cc @@ -220,11 +220,20 @@ void NodeBindings::WakeupEmbedThread() { void NodeBindings::EmbedThreadRunner(void *arg) { NodeBindings* self = static_cast(arg); - while (!self->embed_closed_) { + while (true) { // Wait for the main loop to deal with events. uv_sem_wait(&self->embed_sem_); - + if (self->embed_closed_) + break; + + // Wait for something to happen in uv loop. + // Note that the PollEvents() is implemented by derived classes, so when + // this class is being destructed the PollEvents() would not be available + // anymore. Because of it we must make sure we only invoke PollEvents() + // when this class is alive. self->PollEvents(); + if (self->embed_closed_) + break; // Deal with event in main thread. self->WakeupMainThread();