aboutsummaryrefslogtreecommitdiffstats
path: root/src/event-loop.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2011-10-29 14:27:33 -0400
committerKristian Høgsberg <krh@bitplanet.net>2011-10-29 14:27:33 -0400
commitf86338d611305fb84187298cbab5dfc78a698c99 (patch)
tree7e183f3582d7e691c8a517bcaa2b857b391eccbc /src/event-loop.c
parentscanner: Fix typo in error message (diff)
downloadwayland-f86338d611305fb84187298cbab5dfc78a698c99.tar
wayland-f86338d611305fb84187298cbab5dfc78a698c99.tar.gz
wayland-f86338d611305fb84187298cbab5dfc78a698c99.tar.bz2
wayland-f86338d611305fb84187298cbab5dfc78a698c99.tar.lz
wayland-f86338d611305fb84187298cbab5dfc78a698c99.tar.xz
wayland-f86338d611305fb84187298cbab5dfc78a698c99.tar.zst
wayland-f86338d611305fb84187298cbab5dfc78a698c99.zip
event-loop: Fix idle handler dispatch corner case
When the last idle handler queues another idle handler, we fail to dispatch that last handler. The wl_list_for_each_safe loop looks up the next pointer before running the handler, and at that point it points to the head of the list and the loop terminates. Instead, just loop until the list is empty.
Diffstat (limited to 'src/event-loop.c')
-rw-r--r--src/event-loop.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/event-loop.c b/src/event-loop.c
index 5bd52fd..de1863a 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -434,9 +434,11 @@ post_dispatch_check(struct wl_event_loop *loop)
static void
dispatch_idle_sources(struct wl_event_loop *loop)
{
- struct wl_event_source_idle *source, *next;
+ struct wl_event_source_idle *source;
- wl_list_for_each_safe(source, next, &loop->idle_list, base.link) {
+ while (!wl_list_empty(&loop->idle_list)) {
+ source = container_of(loop->idle_list.next,
+ struct wl_event_source_idle, base.link);
source->func(source->base.data);
wl_event_source_remove(&source->base);
}