SVN commit 936070 by fredrik: Backport r936069. M +17 -10 delegateanimationhandler.cpp M +3 -2 delegateanimationhandler_p.h --- branches/KDE/4.2/kdelibs/kio/kio/delegateanimationhandler.cpp #936069:936070 @@ -110,11 +110,23 @@ DelegateAnimationHandler::DelegateAnimationHandler(QObject *parent) - : QObject(parent), timerId(0) + : QObject(parent) { } +DelegateAnimationHandler::~DelegateAnimationHandler() +{ + timer.stop(); + QMapIterator i(animationLists); + while (i.hasNext()) { + i.next(); + qDeleteAll(*i.value()); + delete i.value(); + } + animationLists.clear(); +} + AnimationState *DelegateAnimationHandler::animationState(const QStyleOption &option, const QModelIndex &index, const QAbstractItemView *view) @@ -216,10 +228,8 @@ state->time.start(); state->animating = true; - if (!timerId) - { - timerId = startTimer(1000 / 30); // 30 fps - } + if (!timer.isActive()) + timer.start(1000 / 30, this); // 30 fps } @@ -290,11 +300,8 @@ activeAnimations += runAnimations(list, view); } - if (activeAnimations == 0 && timerId) - { - killTimer(timerId); - timerId = 0; - } + if (activeAnimations == 0 && timer.isActive()) + timer.stop(); } } --- branches/KDE/4.2/kdelibs/kio/kio/delegateanimationhandler_p.h #936069:936070 @@ -22,6 +22,7 @@ #ifndef DELEGATEANIMATIONHANDLER_P_H #define DELEGATEANIMATIONHANDLER_P_H +#include #include #include #include @@ -80,7 +81,7 @@ public: DelegateAnimationHandler(QObject *parent = 0); - ~DelegateAnimationHandler() {} + ~DelegateAnimationHandler(); AnimationState *animationState(const QStyleOption &option, const QModelIndex &index, const QAbstractItemView *view); @@ -97,7 +98,7 @@ private: QMap animationLists; QTime fadeInAddTime; - int timerId; + QBasicTimer timer; }; }