diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-27 12:24:08 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-27 12:26:16 (GMT) |
commit | 29488d2315c594a273da6b7adb8d238aeca23083 (patch) | |
tree | 09b30f4c7228a511c65d699d869eb1e126675e6d /src | |
parent | a17f89c43bc5e580e9176e825f79005f42a4ad34 (diff) | |
download | Qt-29488d2315c594a273da6b7adb8d238aeca23083.zip Qt-29488d2315c594a273da6b7adb8d238aeca23083.tar.gz Qt-29488d2315c594a273da6b7adb8d238aeca23083.tar.bz2 |
QPropertyAnimation: small refactor and we got rid of QMetaProperty
We don't need QMetaProperty becaus we always try to directly use
the qt_metacall. This allowed for a 24 bytes reduction of the private
class.
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/animation/qpropertyanimation.cpp | 39 | ||||
-rw-r--r-- | src/corelib/animation/qpropertyanimation_p.h | 5 |
2 files changed, 14 insertions, 30 deletions
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 2795208..49862d2 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -92,8 +92,6 @@ #include "qanimationgroup.h" #include "qpropertyanimation_p.h" -#include <QtCore/qmath.h> -#include <QtCore/qmutex.h> #include <private/qmutexpool_p.h> #ifndef QT_NO_ANIMATION @@ -102,23 +100,18 @@ QT_BEGIN_NAMESPACE void QPropertyAnimationPrivate::updateMetaProperty() { - if (!target || propertyName.isEmpty()) + if (!target || propertyName.isEmpty()) { + propertyType = QVariant::Invalid; + propertyIndex = -1; return; - - if (!hasMetaProperty && !property.isValid()) { - const QMetaObject *mo = targetValue->metaObject(); - propertyIndex = mo->indexOfProperty(propertyName); - if (propertyIndex != -1) { - hasMetaProperty = true; - property = mo->property(propertyIndex); - propertyType = property.userType(); - } else { - if (!targetValue->dynamicPropertyNames().contains(propertyName)) - qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); - } } - if (property.isValid()) + propertyType = targetValue->property(propertyName).userType(); + propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName); + if (propertyIndex == -1 && !targetValue->dynamicPropertyNames().contains(propertyName)) + qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); + + if (propertyType != QVariant::Invalid) convertValues(propertyType); } @@ -132,14 +125,10 @@ void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) return; } - if (hasMetaProperty) { - if (newValue.userType() == propertyType) { - //no conversion is needed, we directly call the QObject::qt_metacall - void *data = const_cast<void*>(newValue.constData()); - targetValue->qt_metacall(QMetaObject::WriteProperty, propertyIndex, &data); - } else { - property.write(targetValue, newValue); - } + if (propertyIndex != -1 && newValue.userType() == propertyType) { + //no conversion is needed, we directly call the QObject::qt_metacall + void *data = const_cast<void*>(newValue.constData()); + targetValue->qt_metacall(QMetaObject::WriteProperty, propertyIndex, &data); } else { targetValue->setProperty(propertyName.constData(), newValue); } @@ -199,7 +188,6 @@ void QPropertyAnimation::setTargetObject(QObject *target) } d->target = d->targetValue = target; - d->hasMetaProperty = false; d->updateMetaProperty(); } @@ -225,7 +213,6 @@ void QPropertyAnimation::setPropertyName(const QByteArray &propertyName) } d->propertyName = propertyName; - d->hasMetaProperty = false; d->updateMetaProperty(); } diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h index 4c9360b..3777aa0 100644 --- a/src/corelib/animation/qpropertyanimation_p.h +++ b/src/corelib/animation/qpropertyanimation_p.h @@ -54,7 +54,6 @@ // #include "qpropertyanimation.h" -#include <QtCore/qmetaobject.h> #include "private/qvariantanimation_p.h" @@ -67,7 +66,7 @@ class QPropertyAnimationPrivate : public QVariantAnimationPrivate Q_DECLARE_PUBLIC(QPropertyAnimation) public: QPropertyAnimationPrivate() - : targetValue(0), propertyType(0), propertyIndex(0), hasMetaProperty(false) + : targetValue(0), propertyType(0), propertyIndex(-1) { } @@ -76,11 +75,9 @@ public: QObject *targetValue; //for the QProperty - QMetaProperty property; int propertyType; int propertyIndex; - bool hasMetaProperty; QByteArray propertyName; void updateProperty(const QVariant &); void updateMetaProperty(); |