Skip to content

Commit

Permalink
Fixed SDL_PushEvent() messing up the queue.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 2, 2019
1 parent 59397be commit aba9a59
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/SDL12_compat.c
Expand Up @@ -1314,8 +1314,9 @@ SDL_PollEvent(SDL12_Event *event12)

SDL_PumpEvents(); /* this will run our filter and build our 1.2 queue. */

if (EventQueueHead == NULL)
if (EventQueueHead == NULL) {
return 0; /* no events at the moment. */
}

SDL_memcpy(event12, &EventQueueHead->event12, sizeof (SDL12_Event));
next = EventQueueHead->next;
Expand All @@ -1333,17 +1334,21 @@ DECLSPEC int SDLCALL
SDL_PushEvent(SDL12_Event *event12)
{
EventQueueType *item = EventQueueAvailable;
if (item == NULL)
if (item == NULL) {
return -1; /* no space available at the moment. */
}

EventQueueAvailable = item->next;
if (EventQueueTail)
if (EventQueueTail) {
EventQueueTail->next = item;
else
EventQueueTail = item;
} else {
EventQueueHead = EventQueueTail = item;
}
item->next = NULL;

SDL_memcpy(&item->event12, event12, sizeof (SDL12_Event));

return 0;
}

Expand Down

0 comments on commit aba9a59

Please sign in to comment.