summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation/qpropertyanimation.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-06-03 09:23:33 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-06-03 09:23:33 (GMT)
commitee735a39a333ddff4d5d0734062093ba553850f2 (patch)
tree7801cfb85082a52990314398b2569cc25e5370ce /src/corelib/animation/qpropertyanimation.cpp
parente11ff338951954f08866aef15607e8fae2bc150c (diff)
downloadQt-ee735a39a333ddff4d5d0734062093ba553850f2.zip
Qt-ee735a39a333ddff4d5d0734062093ba553850f2.tar.gz
Qt-ee735a39a333ddff4d5d0734062093ba553850f2.tar.bz2
use of QMutexPool to reduce the number of Q_GLOBAL_STATIC in the
animation framework
Diffstat (limited to 'src/corelib/animation/qpropertyanimation.cpp')
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index 43b5283..357a6ac 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -91,19 +91,17 @@
#include "qpropertyanimation.h"
#include "qanimationgroup.h"
-#include <QtCore/qdebug.h>
-
#include "qpropertyanimation_p.h"
#include <QtCore/qmath.h>
#include <QtCore/qmutex.h>
+#include <private/qmutexpool_p.h>
QT_BEGIN_NAMESPACE
typedef QPair<QObject *, QByteArray> QPropertyAnimationPair;
typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash;
Q_GLOBAL_STATIC(QPropertyAnimationHash, _q_runningAnimations)
-Q_GLOBAL_STATIC_WITH_ARGS(QMutex, guardHashLock, (QMutex::Recursive) )
void QPropertyAnimationPrivate::updateMetaProperty()
{
@@ -284,27 +282,32 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
}
QVariantAnimation::updateState(oldState, newState);
- QMutexLocker locker(guardHashLock());
- QPropertyAnimationHash * hash = _q_runningAnimations();
- QPropertyAnimationPair key(d->target, d->propertyName);
- if (newState == Running) {
- d->updateMetaProperty();
- QPropertyAnimation *oldAnim = hash->value(key, 0);
- if (oldAnim) {
- // try to stop the top level group
- QAbstractAnimation *current = oldAnim;
- while (current->group() && current->state() != Stopped)
- current = current->group();
- current->stop();
- }
- hash->insert(key, this);
- // update the default start value
- if (oldState == Stopped) {
- d->setDefaultStartValue(d->target->property(d->propertyName.constData()));
+ QPropertyAnimation *animToStop = 0;
+ {
+ QPropertyAnimationHash * hash = _q_runningAnimations();
+ QMutexLocker locker(QMutexPool::globalInstanceGet(hash));
+ QPropertyAnimationPair key(d->target, d->propertyName);
+ if (newState == Running) {
+ d->updateMetaProperty();
+ animToStop = hash->value(key, 0);
+ hash->insert(key, this);
+ // update the default start value
+ if (oldState == Stopped) {
+ d->setDefaultStartValue(d->target->property(d->propertyName.constData()));
+ }
+ } else if (hash->value(key) == this) {
+ hash->remove(key);
}
- } else if (hash->value(key) == this) {
- hash->remove(key);
+ }
+
+ //we need to do that after the mutex was unlocked
+ if (animToStop) {
+ // try to stop the top level group
+ QAbstractAnimation *current = animToStop;
+ while (current->group() && current->state() != Stopped)
+ current = current->group();
+ current->stop();
}
}