Jump to content
  • Advertisement
Sign in to follow this  
RawBeen

localizing a crash

This topic is 3547 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've made a small program, game. The game treats input from the mouse. The game works, but, somtimes it just crashes. How do you go about finding the reason for such an event? I'm using Visual Express 2008. but I've tried DevC++ with the same results... It seems to crash only when moving the mouse in a certain way... I mean, I breakpointed around a little, but the game is looping threw the code alot of times before crashing. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Well, the debugger should drop you right to the line the crash happens on. (VS2008, set the project to build debug mode, then run with F5)
Tracking down WHY that line is crashing might be a bit harder.
Check and find out exactly what crashes. Then post some code, and maybe we can point you in a direction to finding out the cause of the crash.

Share this post


Link to post
Share on other sites
Yeah, I've used the debugger, but I've never used it before, so I didn't really know what to expect. It didn't look liked it crashed at all.

I did like: Lazy Foo @ http://lazyfoo.net/articles/article05/index.php

And turns out; the application actually quits, it sets the quit flag to true.


//while there's an event to handle
while( SDL_PollEvent( &event ) )
{

/* some commented out stuff i removed */

//If the user X out the window
if( event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE)
{
log( "Quitting..." );
//quit the program
quit = true;
}
}


It quits, just because i'm moving the mouse?

I'm commenting out "event.key.keysym.sym == SDLK_ESCAPE" for now, and it seems to work...

why would it do that?

[Edited by - RawBeen on January 8, 2009 1:17:47 AM]

Share this post


Link to post
Share on other sites
You probably need to check that the event is actually a key-down (or up) type of event _before_ checking on the actual key.
That is, something along the lines of this: if(event.type == SDL_KEYDOWN && blabla.key == ESCAPE)...

:)

Share this post


Link to post
Share on other sites
Thats probably right, wont look in to it rigt now thow...

...so I guess SDL is flayling keypresses around when it thinks your not looking.

maybe its trying to say something, or is trying to communicate to my hardware or something.

maybe I should try

if( event.type != SDL_KEYDOWN )
{
switch( event.key.keysym.sym )
/*write out the silent keystrokes*/
}

Share this post


Link to post
Share on other sites
Quote:
Original post by RawBeen
...so I guess SDL is flayling keypresses around when it thinks your not looking.
}


Eh, no. The SDL_Event is a union-construct.
You're checking the key-id on an event that has (potentially) nothing todo with the keyboard... Not healthy.

Share this post


Link to post
Share on other sites
if( event.type == SDL_QUIT || event.key.keysym.sym == SDLK_ESCAPE)
Should be:
if( event.type == SDL_QUIT || ( event.type == SDL_KEYBOARD && event.key.keysym.sym == SDLK_ESCAPE))
Or whatever the name of the SDL_KEYBOARD event is.

Also, I'd high recommend reading This for details on using Visual Studio's debugger.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!