From faeaee5f2001038c24b8c94c14dd3d071d590363 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 7 Feb 2019 09:36:08 +1000 Subject: [PATCH] timer: print the timers still in the list before the assert Helps a lot with debugging if we know which timer is still there during cleanup. Signed-off-by: Peter Hutterer --- src/timer.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/timer.c b/src/timer.c index 584673a..3deaf5e 100644 --- a/src/timer.c +++ b/src/timer.c @@ -49,6 +49,13 @@ libinput_timer_init(struct libinput_timer *timer, void libinput_timer_destroy(struct libinput_timer *timer) { + if (timer->link.prev != NULL && timer->link.prev != NULL && + !list_empty(&timer->link)) { + log_bug_libinput(timer->libinput, + "timer: %s has not been cancelled\n", + timer->timer_name); + assert(!"timer not cancelled"); + } free(timer->timer_name); } @@ -200,6 +207,18 @@ libinput_timer_subsys_init(struct libinput *libinput) void libinput_timer_subsys_destroy(struct libinput *libinput) { +#ifndef NDEBUG + if (!list_empty(&libinput->timer.list)) { + struct libinput_timer *t; + + list_for_each(t, &libinput->timer.list, link) { + log_bug_libinput(libinput, + "timer: %s still present on shutdown\n", + t->timer_name); + } + } +#endif + /* All timer users should have destroyed their timers now */ assert(list_empty(&libinput->timer.list)); -- 2.7.4