[SDL] Well, me again having problems with the Key Events...
Doug
biteme at bitbasher.net
Wed Jun 13 02:13:27 PDT 2007
This is just an idea, as I'm not sure if this is your problem or not.
Read this: http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fPumpEvents
Notice two things:
1. SDL_PollEvent() calls SDL_PumpEvents() internally. So if you're calling
SDL_PollEvent() then SDL_PumpEvents() is being invoked implicitly.
2. SDL_PumpEvents() note: You can only call this function in the thread that
set the video mode.
So, I'm wondering if the thread you call SDL_PollEvent() is the same thread
you used to set the video mode. If not, this may or may not be a problem for
you. I've called some SDL functions in threads and I got away with it - maybe
because I used a thread safe SDL function or I was just lucky.
Unfortunately, I have not found a "master list" of which SDL functions are
thread-safe and which are not. Some are documented as such, but I'm not
convinced that all other SDL functions are thread safe.
The only other thing I noticed is this line:
while ( SDL_PollEvent(&evento) || (enviar) ){
This means you can enter your event handler if envair is true but
SDL_PollEvent() returned false. This means the code in the while loop may
possibly be accessing evento members that are not necessarily initialized to
meaningful values. Just a thought.
Doug.
More information about the SDL
mailing list