PDA

View Full Version : Animation problems, after repeated calls to start



pan
9th March 2011, 09:44
I'v set up an animation like this:


animate = new QPropertyAnimation(this,"geometry");
animate->setDuration(800);
QEasingCurve curve = QEasingCurve::OutBack;
curve.setOvershoot(1.5);
animate->setEasingCurve(curve);
connect(animate,SIGNAL(finished()),this,SLOT(finis hedGeometryAnimation()));


The startValue and endValue are changed prior to each call to start()
It all works fine for a while. Then the animation just stops animating.
According the to object it is running, the state says it is running, but the currentTime never changes from 0 and it also never sends a finished signal.

Is there something I'm missing with animations?

To work around this problem I've set up a timer with a duration slightly longer than the animation. If the animation hasn't completed then I force the action I want (move or close). Stop the animation. And call setParent on the animation using the timer event. The next time I call start it animates fine again.

I also am unable to see any consistence in my testing, sometimes it stops working after six animations, sometimes after an hour of testing.

Any pointers to what I am doing wrong will be much appreciated.

Added after 6 minutes:

Actually, the setParent seems to have stopped working as a solution now.

pan
9th March 2011, 14:39
I hate replying to my own questions... no one got any ideas?

I've now noticed that all my animations stop working when one stops working... Is there an event blocking them from running? or an event that is not running properly?

pan
11th March 2011, 13:27
In case anyone has a similar problem in the future, I'll note what my problem was:

I have a lot of widgets and a lot of timers running. But in one of my widgets, which animated, I had a timer which was being started and killed with startTimer and killTimer(int). This timer was being started everytime the widget animated (almost every click of the mouse) and killed between 250 and 500ms later.

What I discovered, by putting break points in qt's animation code, was that the animation timer had died without my animation telling it to do so, and there was no way of restarting it.

Removing the timer (very unnecessary code) from my animated widget seems to have fixed the problem. - using singleshot, instead of start and kill, also worked.

My guess, very wild because I haven't been able to reproduce this in a small application to prove it one way or another, is that I was getting the timerID that was already given to the animation startstoptimer, and my widget was killing this timer, and thus the animation.