Skip to content

Commit

Permalink
timer: print the timers still in the list before the assert
Browse files Browse the repository at this point in the history
Helps a lot with debugging if we know which timer is still there during
cleanup.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Feb 11, 2019
1 parent 7db3233 commit faeaee5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit faeaee5

Please sign in to comment.