So, I have a wxTimer in wxAnimatePng that gets updated every 10ms and figures out whether it's time to go to the next frame in the animation. At the end of the timer event handler, I put a parent->Refresh() so that the panel in MyFrame gets refreshed. This is necessary for the next frame of the animation to get updated and drawn.
This works perfectly while the app is running, but as soon as I close the window, it always throws this error:
When I comment out the line with parent->Refresh(), it doesn't update the animation, but it also doesn't throw that error when the window is closed.Unhandled exception at 0x778715ee in testanimate.exe: 0xC0000005: Access violation reading location 0xfeef0006.
Here is my timer code:
Code: Select all
void wxAnimatePng::OnTimer(wxTimerEvent &event)
{
currentTime += 10;
if(currentTime > frameTime[currentFrame])
{
currentTime = 0;
currentFrame++;
if(currentFrame > frame.size()-1)
{
if(frame.size() > 1)
currentFrame = 1;
else
currentFrame = 0;
}
}
parent->Refresh();
}
Any ideas?