Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1113 - SDL_SetEventFilter()'s event deletion process is not…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
slouken committed May 21, 2013
1 parent 5f6ef90 commit 6aabd8c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/events/SDL_events.c
Expand Up @@ -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
Expand Down

0 comments on commit 6aabd8c

Please sign in to comment.