summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
authorLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-08-27 18:19:22 +0200
committerLeonardo Sobral Cunha <leo.cunha@nokia.com>2009-08-28 11:24:50 +0200
commit7091ec8cd1ec94fb889230d69fc70d40a9f69b2d (patch)
tree61932b3ba965485ef3d362bd06db9bbb90b4bcdc /src/corelib/animation
parent2d668d870d4acd90e0ee4ff27e65e92fd311ce22 (diff)
QAbstractAnimation: replacing QPointer usage for QWeakPointer
Added guard checks after the virtual method calls. Reviewed-by: thierry
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index dfd6779123..49bd8e9142 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -259,28 +259,33 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
}
state = newState;
- QPointer<QAbstractAnimation> guard(q);
+ QWeakPointer<QAbstractAnimation> guard(q);
- guard->updateState(oldState, newState);
+ q->updateState(oldState, newState);
+ if (!guard)
+ return;
//this is to be safe if updateState changes the state
if (state == oldState)
return;
// Notify state change
- if (guard)
- emit guard->stateChanged(oldState, newState);
+ emit q->stateChanged(oldState, newState);
+ if (!guard)
+ return;
- switch (state)
- {
+ switch (state) {
case QAbstractAnimation::Paused:
case QAbstractAnimation::Running:
//this ensures that the value is updated now that the animation is running
- if(oldState == QAbstractAnimation::Stopped && guard)
- guard->setCurrentTime(currentTime);
+ if(oldState == QAbstractAnimation::Stopped) {
+ q->setCurrentTime(currentTime);
+ if (!guard)
+ return;
+ }
// Register timer if our parent is not running.
- if (state == QAbstractAnimation::Running && guard) {
+ if (state == QAbstractAnimation::Running) {
if (!group || group->state() == QAbstractAnimation::Stopped) {
QUnifiedTimer::instance()->registerAnimation(q);
}
@@ -292,7 +297,10 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
case QAbstractAnimation::Stopped:
// Leave running state.
int dura = q->duration();
- if (deleteWhenStopped && guard)
+ if (!guard)
+ return;
+
+ if (deleteWhenStopped)
q->deleteLater();
QUnifiedTimer::instance()->unregisterAnimation(q);
@@ -300,8 +308,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
if (dura == -1 || loopCount < 0
|| (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
|| (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) {
- if (guard)
- emit q->finished();
+ emit q->finished();
}
break;
}