diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 314983107..f9b8dca3e 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -873,6 +873,11 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel) if (push_sentinel && SDL_EventEnabled(SDL_EVENT_POLL_SENTINEL)) { SDL_Event sentinel; + /* Make sure we don't already have a sentinel in the queue, and add one to the end */ + if (SDL_AtomicGet(&SDL_sentinel_pending) > 0) { + SDL_PeepEventsInternal(&sentinel, 1, SDL_GETEVENT, SDL_EVENT_POLL_SENTINEL, SDL_EVENT_POLL_SENTINEL, SDL_TRUE); + } + sentinel.type = SDL_EVENT_POLL_SENTINEL; sentinel.common.timestamp = 0; SDL_PushEvent(&sentinel); @@ -915,11 +920,7 @@ static int SDL_WaitEventTimeout_Device(SDL_VideoDevice *_this, SDL_Window *wakeu c) Periodic processing that takes place in some platform PumpEvents() functions happens d) Signals received in WaitEventTimeout() are turned into SDL events */ - /* We only want a single sentinel in the queue. We could get more than one if event is NULL, - * since the SDL_PeepEvents() call below won't remove it in that case. - */ - SDL_bool add_sentinel = (SDL_AtomicGet(&SDL_sentinel_pending) == 0) ? SDL_TRUE : SDL_FALSE; - SDL_PumpEventsInternal(add_sentinel); + SDL_PumpEventsInternal(SDL_TRUE); SDL_LockMutex(_this->wakeup_lock); {