Fixed bug 1113 - SDL_SetEventFilter()'s event deletion process is not safe against intervening event push.

This is not completely thread-safe since it's possible for an event to come in and be unfiltered between the flush call and the setting of the new filter, but it's much better than it was.
This commit is contained in:
Sam Lantinga 2013-05-20 23:04:25 -07:00
parent 97fba74bda
commit 3d5e0ce562

View file

@ -388,12 +388,11 @@ SDL_PushEvent(SDL_Event * event)
void
SDL_SetEventFilter(SDL_EventFilter filter, void *userdata)
{
SDL_Event bitbucket;
/* Set filter and discard pending events */
SDL_EventOK = filter;
SDL_EventOK = NULL;
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
SDL_EventOKParam = userdata;
while (SDL_PollEvent(&bitbucket) > 0);
SDL_EventOK = filter;
}
SDL_bool