Weird Bug

Started by
0 comments, last by matthughson 18 years, 10 months ago
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
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]
Advertisement
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
__________________________________[ Website ] [ Résumé ] [ [email=contact[at]matthughson[dot]com]Contact[/email] ][ Have I been Helpful? Hook me up! ]

This topic is closed to new replies.

Advertisement