diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-06-03 09:23:33 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-06-03 09:23:33 (GMT) |
commit | ee735a39a333ddff4d5d0734062093ba553850f2 (patch) | |
tree | 7801cfb85082a52990314398b2569cc25e5370ce /src/corelib/animation/qvariantanimation.cpp | |
parent | e11ff338951954f08866aef15607e8fae2bc150c (diff) | |
download | Qt-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/qvariantanimation.cpp')
-rw-r--r-- | src/corelib/animation/qvariantanimation.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index e973ec5..a3fa93a 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -44,11 +44,10 @@ #include "qvariantanimation.h" #include "qvariantanimation_p.h" -#include <QtCore/QRect> -#include <QtCore/QLineF> -#include <QtCore/QLine> -#include <QtCore/QReadWriteLock> -#include <QtCore/qdebug.h> +#include <QtCore/qrect.h> +#include <QtCore/qline.h> +#include <QtCore/qmutex.h> +#include <private/qmutexpool_p.h> QT_BEGIN_NAMESPACE @@ -365,8 +364,8 @@ void QVariantAnimation::setEasingCurve(const QEasingCurve &easing) d->recalculateCurrentInterval(); } -Q_GLOBAL_STATIC(QVector<QVariantAnimation::Interpolator>, registeredInterpolators) -Q_GLOBAL_STATIC(QReadWriteLock, registeredInterpolatorsLock) +typedef QVector<QVariantAnimation::Interpolator> QInterpolatorVector; +Q_GLOBAL_STATIC(QInterpolatorVector, registeredInterpolators) /*! \fn void qRegisterAnimationInterpolator(QVariant (*func)(const T &from, const T &to, qreal progress)) @@ -398,10 +397,11 @@ Q_GLOBAL_STATIC(QReadWriteLock, registeredInterpolatorsLock) void QVariantAnimation::registerInterpolator(QVariantAnimation::Interpolator func, int interpolationType) { // will override any existing interpolators - QWriteLocker locker(registeredInterpolatorsLock()); - if (int(interpolationType) >= registeredInterpolators()->count()) - registeredInterpolators()->resize(int(interpolationType) + 1); - registeredInterpolators()->replace(interpolationType, func); + QInterpolatorVector *interpolators = registeredInterpolators(); + QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); + if (int(interpolationType) >= interpolators->count()) + interpolators->resize(int(interpolationType) + 1); + interpolators->replace(interpolationType, func); } @@ -412,10 +412,11 @@ template<typename T> static inline QVariantAnimation::Interpolator castToInterpo QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator(int interpolationType) { - QReadLocker locker(registeredInterpolatorsLock()); + QInterpolatorVector *interpolators = registeredInterpolators(); + QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators)); QVariantAnimation::Interpolator ret = 0; - if (interpolationType < registeredInterpolators()->count()) { - ret = registeredInterpolators()->at(interpolationType); + if (interpolationType < interpolators->count()) { + ret = interpolators->at(interpolationType); if (ret) return ret; } |