diff --git a/atom/app/uv_task_runner.cc b/atom/app/uv_task_runner.cc index 23463e44e2e..f49ba259bac 100644 --- a/atom/app/uv_task_runner.cc +++ b/atom/app/uv_task_runner.cc @@ -48,8 +48,13 @@ void UvTaskRunner::OnTimeout(uv_timer_t* timer) { self->tasks_[timer].Run(); self->tasks_.erase(timer); - uv_unref(reinterpret_cast(timer)); - delete timer; + uv_timer_stop(timer); + uv_close(reinterpret_cast(timer), UvTaskRunner::OnClose); +} + +// static +void UvTaskRunner::OnClose(uv_handle_t* handle) { + delete reinterpret_cast(handle); } } // namespace atom diff --git a/atom/app/uv_task_runner.h b/atom/app/uv_task_runner.h index e4eac015535..c7302766c2d 100644 --- a/atom/app/uv_task_runner.h +++ b/atom/app/uv_task_runner.h @@ -31,6 +31,7 @@ class UvTaskRunner : public base::SingleThreadTaskRunner { private: static void OnTimeout(uv_timer_t* timer); + static void OnClose(uv_handle_t* handle); uv_loop_t* loop_;