Sign in to follow this  
matthughson

Weird Bug

Recommended Posts

matthughson    588
Hey All, I've got this weird bug in my engine with regards to my stopwatch (timer) class. It seems to be getting filled with garbage, but only when it is declared in certain places. For example, if I make the stopwatch instance a member of the class I'm working on, when i call its 'getElapsedTime' function, it returns a garbage value (the same one every time actually). However, if I declare it as a local member of one of the classes functions, it actually works perfectly! My guess is I've over run some memory somewhere, but I can't seem to find anything. So I'm wondering if this behaviour points anyone in a certain direction to what the problem may be. I have installed a memory manager, which detects no leaks. And when I turn on it's stress tester, the timer works perfectly no matter where it's declared! Sigh... Thanks guys, Matt Hughson

Share this post


Link to post
Share on other sites
matthughson    588
hehe nevermind [embarrass]

Turns out the problem was that the object with the timer was being created before the main game timer (which the stopwatch depends on for calculations). Thus, when the stopwatch was created as a member its timer was messed up. But when i made it a local variable in a function it got recreated every frame, and by that time the main game timer had been initialized.

Thanks anyway though!
Matt Hughson

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this