summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation/qabstractanimation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/animation/qabstractanimation.cpp')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 77c6188e2f..f399d7c4cf 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -167,7 +167,7 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
QUnifiedTimer::QUnifiedTimer() :
QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
- insideTick(false), currentAnimationIdx(0), consistentTiming(false), slowMode(false),
+ currentAnimationIdx(0), insideTick(false), consistentTiming(false), slowMode(false),
slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0)
{
time.invalidate();
@@ -423,6 +423,15 @@ void QUnifiedTimer::uninstallAnimationDriver(QAnimationDriver *d)
}
}
+/*!
+ Returns true if \a d is the currently installed animation driver
+ and is not the default animation driver (which can never be uninstalled).
+*/
+bool QUnifiedTimer::canUninstallAnimationDriver(QAnimationDriver *d)
+{
+ return d == driver && driver != &defaultDriver;
+}
+
/*!
\class QAnimationDriver
@@ -446,6 +455,12 @@ QAnimationDriver::QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent)
{
}
+QAnimationDriver::~QAnimationDriver()
+{
+ QUnifiedTimer *timer = QUnifiedTimer::instance(true);
+ if (timer->canUninstallAnimationDriver(this))
+ uninstall();
+}
/*!
Advances the animation based on the current time. This function should