--- a/src/events/SDL_events.c Sun Oct 14 01:05:04 2012 -0700
+++ b/src/events/SDL_events.c Sun Oct 14 01:30:42 2012 -0700
@@ -63,7 +63,7 @@
SDL_Event event[MAXEVENTS];
int wmmsg_next;
struct SDL_SysWMmsg wmmsg[MAXEVENTS];
-} SDL_EventQ;
+} SDL_EventQ = { NULL, 1 };
static __inline__ SDL_bool
@@ -117,18 +117,21 @@
int
SDL_StartEventLoop(void)
{
- /* Clean out the event queue */
- SDL_EventQ.lock = NULL;
- SDL_StopEventLoop();
+ /* We'll leave the event queue alone, since we might have gotten
+ some important events at launch (like SDL_DROPFILE)
+
+ FIXME: Does this introduce any other bugs with events at startup?
+ */
/* No filter to start with, process most event types */
SDL_EventOK = NULL;
- SDL_EventState(SDL_DROPFILE, SDL_DISABLE);
SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
/* Create the lock and set ourselves active */
#if !SDL_THREADS_DISABLED
- SDL_EventQ.lock = SDL_CreateMutex();
+ if (!SDL_EventQ.lock) {
+ SDL_EventQ.lock = SDL_CreateMutex();
+ }
if (SDL_EventQ.lock == NULL) {
return (-1);
}
@@ -207,7 +210,7 @@
}
/* Lock the event queue */
used = 0;
- if (SDL_mutexP(SDL_EventQ.lock) == 0) {
+ if (!SDL_EventQ.lock || SDL_mutexP(SDL_EventQ.lock) == 0) {
if (action == SDL_ADDEVENT) {
for (i = 0; i < numevents; ++i) {
used += SDL_AddEvent(&events[i]);
@@ -374,7 +377,6 @@
}
SDL_GestureProcessEvent(event);
-
return 1;
}