I've a block of code where I've used Qt's new animation framework. I needed the animation just in that block of code and I don't need the animation related variables in other places. Clearly, the animation won't work if it is destroyed before the animation completed. For example, the following doesn't work:
if (animate)
{
QPropertyAnimation animation(_piece_images[svg_index].getImage(), "pos");
animation.setDuration(200);
animation.setEndValue(getCellPos(row, col));
animation.setEasingCurve(QEasingCurve::InOutSine);
animation.start();
}
So I'm using animation using pointer:
if (animate)
{
QPropertyAnimation *animation = new
QPropertyAnimation(_piece_images[svg_index].getImage(), "pos");
animation->setDuration(200);
animation->setEndValue(getCellPos(row, col));
animation->setEasingCurve(QEasingCurve::InOutSine);
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
My question is, is there any memory leak in the above solution? Please provide reference if possible, probably I've missed something.