Profile: Fix leak in animation

If animDelete() was called with prefs.animation_speed == 0, the
object would not be marked for deletion, as opposed to calling
with prefs.animation_speed != 0. This would leak the objects.

Therefore delete the objects if called with prefs.animation_speed == 0.
The caller doesn't keep a reference to the objects. Therefore,
a plain delete is fine, as opposed to a deleteLater().

While touching this function, use the function-pointer version
of connect().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-05-18 23:09:11 +02:00 committed by Dirk Hohndel
parent ffdaba6c84
commit 555f2f9565

View file

@ -33,12 +33,12 @@ namespace Animations {
{
if (prefs.animation_speed != 0) {
QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
obj->connect(animation, SIGNAL(finished()), SLOT(deleteLater()));
obj->connect(animation, &QPropertyAnimation::finished, &QObject::deleteLater);
animation->setStartValue(1);
animation->setEndValue(0);
animation->start(QAbstractAnimation::DeleteWhenStopped);
} else {
obj->setProperty("opacity", 0);
delete obj;
}
}