SDL_PollEvent() is behaving badly

Ok, ignoring the fact that SDL_Quit is crashing when the program exits, I
noticed that sometimes the polygon for my player (asteroids clone still) is
not the one I loaded from disk. It only happens sometimes, but always it’s
the same polygon. I walked through my source code (with gdb and ddd), and
the polygon is loaded from the file correctly. Then a little later on in
the code, when I enter my main loop for the first time, a call to
SDL_PollEvent() changes the value of my polygon. At this time, I’m
thinking two things: A) I’ve completely lost my mind and have no idea
what’s going on, B) Most of this code was working 6 months ago, and now it
acts oddly. Anyone have any help?–

  • Mik Mifflin

This smells a lot like memory corruption. When images start changing
like
that it is almost always that the memory is being overwritten. Some
debugers
will let you trap writes to an range of addresses. Find one and use it.
After
your code has loaded the image, set a trap on the addresses of the
surface
structure and the pixels and then watch what happens as the code runs.

		Bob Pendleton

Mik Mifflin wrote:>

Ok, ignoring the fact that SDL_Quit is crashing when the program exits, I
noticed that sometimes the polygon for my player (asteroids clone still) is
not the one I loaded from disk. It only happens sometimes, but always it’s
the same polygon. I walked through my source code (with gdb and ddd), and
the polygon is loaded from the file correctly. Then a little later on in
the code, when I enter my main loop for the first time, a call to
SDL_PollEvent() changes the value of my polygon. At this time, I’m
thinking two things: A) I’ve completely lost my mind and have no idea
what’s going on, B) Most of this code was working 6 months ago, and now it
acts oddly. Anyone have any help?

  • Mik Mifflin

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-----------------------------------+

  • Bob Pendleton is seeking contract +
  • and consulting work. Find out more +
  • at http://www.jump.net/~bobp +
    ±-----------------------------------+