From d6d8073939dd3c74358dea19b86d49c9bc212754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Linse?= Date: Sat, 28 May 2016 11:16:03 +0200 Subject: [PATCH] timers: stop all timers on teardown --- src/nvim/eval.c | 10 +++++++++- src/nvim/main.c | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index e6f40a0bb8..92e572db2f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16569,7 +16569,7 @@ static void timer_due_cb(TimeWatcher *tw, void *data) { timer_T *timer = (timer_T *)data; if (timer->stopped) { - return; + return; } // if repeat was negative repeat forever if (timer->repeat_count >= 0 && --timer->repeat_count == 0) { @@ -16609,6 +16609,14 @@ static void timer_free_cb(TimeWatcher *tw, void *data) xfree(timer); } +void timer_teardown(void) +{ + timer_T *timer; + map_foreach_value(timers, timer, { + timer_stop(timer); + }) +} + /* * "tolower(string)" function */ diff --git a/src/nvim/main.c b/src/nvim/main.c index 2b14e6a777..ba545c0815 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -161,6 +161,7 @@ void event_teardown(void) input_stop(); channel_teardown(); process_teardown(&main_loop); + timer_teardown(); server_teardown(); signal_teardown(); terminal_teardown();