PollEvent inconsistency?

If I first use SDL_PollEvent(NULL) and then SDL_PollEvent(&event) with some non-NULL event, and sometimes get different results. Namely, the first one returns true as if there was some event, and the second one returns false… How come ?

In the same loop, if I only use SDL_PollEvent(&event) I also get false

From this I tend to think that SDL_PollEvent(NULL) is not reliable: there must be a bug?

(this is SDL 2.0.18)

To be precise, this is on Mac OS with SDL 2.0.18 on a VirtualBox.
On my native Linux with SDL 2.0.10, there is no problem at all.

This should be fixed:

However, calling SDL_PollEvent(NULL) duplicates the work of SDL_PollEvent(&event), so if you’re able to handle the events right away, you should just call SDL_PollEvent(&event) directly.

1 Like

many thanks for the quick answer (and fix!)

Do you know which versions of SDL2 are impacted?

Just to be sure, I will remove in my app all SDL_PollEvent(NULL) and replace them
by SDL_PollEvent(&event) (even when I don’t need the event.)

This should just affect 2.0.18.