-
July 19th, 2011, 08:00 PM
#1
unhandled exception?
Hello, what this function is suppose to do is wait for the user to either click button one, button two, or ex out the program. Instead, i get this error:
Code:
Unhandled exception at 0x00973faa in TicTacToe v2.0.exe: 0xC0000005:
Access violation reading location 0xfeeefeee.
Here is the code that triggers this error:
Code:
void Title::HandleEvents()
{
SDL_Event event;
//While there's events to handle
while( SDL_PollEvent( &event ) )
{
if( event.type == SDL_MOUSEBUTTONDOWN )
{
if( event.button.button == SDL_BUTTON_LEFT )
{
int x = event.button.x;
int y = event.button.y;
if( (x > 200 && x < 300) && (y > 160 && y < 200 ) )
{
SetNextState( STATE_TITLE, STATE_1PLAYER );
}
if( (x > 330 && x < 430) && (y > 160 && y < 200 ) )
{
SetNextState( STATE_TITLE, STATE_2PLAYER );
}
}
}
if( event.type == SDL_QUIT )
{
//Quit the program
SetNextState( STATE_TITLE, STATE_EXIT );
}
}
}
-
July 20th, 2011, 10:28 AM
#2
Re: unhandled exception?
Have you run it in the debugger to see what line of your code is causing this?
Viggy
-
July 20th, 2011, 03:31 PM
#3
Re: unhandled exception?
@viggy:
The problem is inside of a while loop that waits for an event, so when i debug look like i cant see what the exact line of code.
-
July 20th, 2011, 03:55 PM
#4
Re: unhandled exception?
You should have a stack trace that shows what call inside your code ultimately leads to the exception. Then, you look to see that all your variables are what you expect them to be.
Viggy
-
July 20th, 2011, 04:26 PM
#5
Re: unhandled exception?
@viggy: not really sure how to do that but here is the project so you can take a look at it.
http://www.mediafire.com/?722s9rsjneo51bw
-
July 20th, 2011, 06:34 PM
#6
Re: unhandled exception?
In visual studio 2005 (and probably later ones too) there is a little icon that looks like a window with three little windows on top of it. Hovering your mouse over it shows the label "Call Stack". Clicking this at a breakpoint or error will bring up a window at the bottom that shows the whole history of the program up until that point. You can double-click each line to take you to the section of code, and hovering your mouse over any variable should tell you what it equals.
Do this, and you will find the source of your problem.
-
July 20th, 2011, 06:57 PM
#7
Re: unhandled exception?
@ quantumcat:
I clicked what you said but all that happend was a box came up with a graph of weird letters and stuff. If i doubled click a line it just brought up some weird .cpp's.
-
July 24th, 2011, 03:50 PM
#8
Re: unhandled exception?
Have you tried setting a break point on the first line in SetNextState and single step from that point?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|