From 6b31fb5a4bfd634f5af6ee30e637d81101d1d62b Mon Sep 17 00:00:00 2001 From: Thomas Brand Date: Sat, 25 Mar 2023 02:20:57 +0100 Subject: X11: Fix puglStopTimer() with multiple timers --- src/x11.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/x11.c b/src/x11.c index 5dc92e5..4377f77 100644 --- a/src/x11.c +++ b/src/x11.c @@ -1409,16 +1409,14 @@ puglStopTimer(PuglView* const view, const uintptr_t id) if (w->timers[i].view == view && w->timers[i].id == id) { XSyncDestroyAlarm(w->display, w->timers[i].alarm); - if (i == w->numTimers - 1) { - memset(&w->timers[i], 0, sizeof(PuglTimer)); - } else { + if (i != w->numTimers - 1) { memmove(w->timers + i, w->timers + i + 1, sizeof(PuglTimer) * (w->numTimers - i - 1)); - - memset(&w->timers[i], 0, sizeof(PuglTimer)); } + memset(&w->timers[w->numTimers - 1], 0, sizeof(PuglTimer)); + --w->numTimers; return PUGL_SUCCESS; } -- cgit v1.2.1