aboutsummaryrefslogtreecommitdiffstats
path: root/src/x11.c
diff options
context:
space:
mode:
authorThomas Brand <tom@trellis.ch>2023-03-25 02:20:57 +0100
committerDavid Robillard <d@drobilla.net>2023-05-22 13:10:54 -0400
commit6b31fb5a4bfd634f5af6ee30e637d81101d1d62b (patch)
treeff61bbad0926f395da8ba6c9f75c4dc0d713920e /src/x11.c
parentb3f68b0c17edb686749ad2e595476ed971af01e3 (diff)
downloadpugl-6b31fb5a4bfd634f5af6ee30e637d81101d1d62b.tar.gz
pugl-6b31fb5a4bfd634f5af6ee30e637d81101d1d62b.tar.bz2
pugl-6b31fb5a4bfd634f5af6ee30e637d81101d1d62b.zip
X11: Fix puglStopTimer() with multiple timers
Diffstat (limited to 'src/x11.c')
-rw-r--r--src/x11.c8
1 files changed, 3 insertions, 5 deletions
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;
}