Use a dedicated timer for the animation driver.
QUnifiedTimer::elapsed() was implemented using driverStartTime + time.elapsed() while the driver was running, but time.elapsed already contains driverStartTime so that was counted twice. This caused repeating timers to fire immediately once they first had fired, if the animation driver was started while it was running. Separate the two timers. Animation driver time restarts from 0 every time it starts. Change-Id: Icf5cd0381b121b2355d7c6ec3edd0997721cbcdf Task-number: QTBUG-41198 Reviewed-by: Michael Brasser <michael.brasser@live.com>
This commit is contained in:
parent
f40b4cd89c
commit
0db3ea4048
@ -877,6 +877,7 @@ void QAnimationDriver::start()
|
||||
Q_D(QAnimationDriver);
|
||||
if (!d->running) {
|
||||
d->running = true;
|
||||
d->timer.start();
|
||||
emit started();
|
||||
}
|
||||
}
|
||||
@ -900,9 +901,8 @@ void QAnimationDriver::stop()
|
||||
|
||||
qint64 QAnimationDriver::elapsed() const
|
||||
{
|
||||
// The default implementation picks up the elapsed time from the
|
||||
// unified timer and can ignore the time offset.
|
||||
return QUnifiedTimer::instance()->time.elapsed();
|
||||
Q_D(const QAnimationDriver);
|
||||
return d->running ? d->timer.elapsed() : 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -133,6 +133,7 @@ class Q_CORE_EXPORT QAnimationDriverPrivate : public QObjectPrivate
|
||||
{
|
||||
public:
|
||||
QAnimationDriverPrivate() : running(false) {}
|
||||
QElapsedTimer timer;
|
||||
bool running;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user