diff options
author | Martin Jones <martin.jones@nokia.com> | 2009-11-30 22:42:33 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2009-11-30 22:42:33 (GMT) |
commit | c20ff1f36b8f5ba47e0358c4d63eed408c97b993 (patch) | |
tree | c22afede4c09982c76ad03b81ea62d6207d175eb /src/declarative/util/qmlanimation_p_p.h | |
parent | 81542982a9b7f4d55707ec6abfd26f5046871f88 (diff) | |
download | Qt-c20ff1f36b8f5ba47e0358c4d63eed408c97b993.zip Qt-c20ff1f36b8f5ba47e0358c4d63eed408c97b993.tar.gz Qt-c20ff1f36b8f5ba47e0358c4d63eed408c97b993.tar.bz2 |
Fix PropertyAction crash.
It is possible for the animation to stop while in doAction(),
which would then delete the animations we were running.
Diffstat (limited to 'src/declarative/util/qmlanimation_p_p.h')
-rw-r--r-- | src/declarative/util/qmlanimation_p_p.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index cb1c642..326e1c6 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -64,6 +64,7 @@ #include <qml.h> #include <qmlcontext.h> #include <private/qmltimeline_p_p.h> +#include <QDebug> QT_BEGIN_NAMESPACE @@ -94,9 +95,9 @@ class QActionAnimation : public QAbstractAnimation { Q_OBJECT public: - QActionAnimation(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped) {} + QActionAnimation(QObject *parent = 0) : QAbstractAnimation(parent), animAction(0), policy(KeepWhenStopped), running(false) {} QActionAnimation(QAbstractAnimationAction *action, QObject *parent = 0) - : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped) {} + : QAbstractAnimation(parent), animAction(action), policy(KeepWhenStopped), running(false) {} virtual int duration() const { return 0; } void setAnimAction(QAbstractAnimationAction *action, DeletionPolicy p) { @@ -111,17 +112,27 @@ protected: virtual void updateState(State newState, State /*oldState*/) { if (newState == Running) { - if (animAction) + if (animAction) { + running = true; animAction->doAction(); + running = false; + if (state() == Stopped && policy == DeleteWhenStopped) { + delete animAction; + animAction = 0; + } + } } else if (newState == Stopped && policy == DeleteWhenStopped) { - delete animAction; - animAction = 0; + if (!running) { + delete animAction; + animAction = 0; + } } } private: QAbstractAnimationAction *animAction; DeletionPolicy policy; + bool running; }; //animates QmlTimeLineValue (assumes start and end values will be reals or compatible) |