summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Kristensen <thkriste@cisco.com>2013-03-13 13:53:06 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-26 19:42:13 +0100
commit3eb583f6e6e0075583aea7dbf46cf3cec48cb879 (patch)
treec15f8bb78e0e69eab0b5f6df2a823661b99c32c4
parent983d006ddf09b2ee81ae7aca599e899ca3239858 (diff)
Fix a bug where completed was emitted twice when duration was zero.v5.1.0-alpha1
Change-Id: I72c16f3affb297985e9e5d2e9f524537212d06ad Reviewed-by: Michael Brasser <michael.brasser@live.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com> Reviewed-by: Andreas Aardal Hanssen <andreas@hanssen.name>
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp4
-rw-r--r--tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp20
2 files changed, 20 insertions, 4 deletions
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 83bfa170..a72df77a 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -160,10 +160,6 @@ void QDeclarativeAbstractAnimationPrivate::commence()
q->transition(actions, properties, QDeclarativeAbstractAnimation::Forward);
q->qtAnimation()->start();
- if (q->qtAnimation()->state() != QAbstractAnimation::Running) {
- running = false;
- emit q->completed();
- }
}
QDeclarativeProperty QDeclarativeAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj)
diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
index 00869268..6352d02b 100644
--- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
+++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp
@@ -47,6 +47,7 @@
#include <private/qdeclarativeitem_p.h>
#include <QVariantAnimation>
#include <QEasingCurve>
+#include <QSignalSpy>
class tst_qdeclarativeanimations : public QObject
{
@@ -82,6 +83,7 @@ private slots:
void doubleRegistrationBug();
void alwaysRunToEndRestartBug();
void transitionAssignmentBug();
+ void zeroDurationTwoCompletedEmittedBug();
};
#define QTIMED_COMPARE(lhs, rhs) do { \
@@ -850,6 +852,24 @@ void tst_qdeclarativeanimations::transitionAssignmentBug()
QCOMPARE(rect->property("nullObject").toBool(), false);
}
+void tst_qdeclarativeanimations::zeroDurationTwoCompletedEmittedBug()
+{
+ QDeclarativeRectangle rect;
+ QDeclarativePropertyAnimation animation;
+ animation.setTarget(&rect);
+ animation.setProperty("x");
+ animation.setFrom(1);
+ animation.setTo(200);
+ animation.setDuration(0);
+ QVERIFY(animation.from() == 1);
+ QSignalSpy spy(&animation, SIGNAL(completed(void)));
+ animation.start();
+ QVERIFY(!animation.isRunning());
+ QCOMPARE(rect.x(), qreal(200));
+ QCOMPARE(spy.size(), 1);
+}
+
+
QTEST_MAIN(tst_qdeclarativeanimations)
#include "tst_qdeclarativeanimations.moc"