From 560d32ddd80d5c6b21cd39ae93ea3f580da613da Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 7 Dec 2009 13:08:22 +1000 Subject: Minor cleanup/optimization. --- src/declarative/graphicsitems/qmlgraphicsitem_p.h | 2 -- src/declarative/graphicsitems/qmlgraphicstext_p_p.h | 10 +++++----- src/declarative/util/qmlanimation.cpp | 14 +++++++++++--- src/declarative/util/qmlanimation_p_p.h | 9 +++++---- src/declarative/util/qmltransition.cpp | 17 +++++++---------- 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h index 82950c2..a8d77ea 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h @@ -119,8 +119,6 @@ public: heightIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("heightChanged()"); } } - ~QmlGraphicsItemPrivate() - { delete _anchors; } void init(QmlGraphicsItem *parent) { diff --git a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h index 0ddae57..6fbee50 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h @@ -101,11 +101,11 @@ public: QPixmap imgStyleCache; QmlGraphicsText::HAlignment hAlign; QmlGraphicsText::VAlignment vAlign; - QmlGraphicsText::TextElideMode elideMode; - bool dirty; - bool wrap; - bool richText; - bool singleline; + QmlGraphicsText::TextElideMode elideMode; + bool dirty:1; + bool wrap:1; + bool richText:1; + bool singleline:1; QTextControl *control; QTextDocument *doc; QTextLayout layout; diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 00e3056..0143791 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1608,9 +1608,6 @@ void QmlPropertyAnimationPrivate::init() Q_Q(QmlPropertyAnimation); va = new QmlTimeLineValueAnimator; QmlGraphics_setParent_noEvent(va, q); - - va->setStartValue(QVariant(0.0f)); - va->setEndValue(QVariant(1.0f)); } /*! @@ -2022,6 +2019,12 @@ void QmlPropertyAnimation::prepare(QmlMetaProperty &p) else d->property = d->userProperty; + if (!d->rangeIsSet) { + d->va->setStartValue(QVariant(0.0f)); + d->va->setEndValue(QVariant(1.0f)); + d->rangeIsSet = true; + } + int propType = d->property.propertyType(); d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType); if (d->fromIsDefined) @@ -2179,6 +2182,11 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, } if (data->actions.count()) { + if (!d->rangeIsSet) { + d->va->setStartValue(QVariant(0.0f)); + d->va->setEndValue(QVariant(1.0f)); + d->rangeIsSet = true; + } d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); } else { delete data; diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index 71b6caa..71fa9a3 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -343,7 +343,7 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate public: QmlPropertyAnimationPrivate() : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false), - defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), + rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), value(this, &QmlPropertyAnimationPrivate::valueChanged) {} void init(); @@ -358,9 +358,10 @@ public: QList exclude; bool fromSourced; - bool fromIsDefined; - bool toIsDefined; - bool defaultToInterpolatorType; + bool fromIsDefined:1; + bool toIsDefined:1; + bool rangeIsSet:1; + bool defaultToInterpolatorType:1; int interpolatorType; QVariantAnimation::Interpolator interpolator; diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index dad6c37..b96ff61 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -83,7 +83,7 @@ class QmlTransitionPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlTransition) public: QmlTransitionPrivate() : fromState(QLatin1String("*")), toState(QLatin1String("*")) - , reversed(false), reversible(false), group(0), endState(0) + , reversed(false), reversible(false), endState(0) { animations.parent = this; } @@ -92,13 +92,12 @@ public: QString toState; bool reversed; bool reversible; - ParallelAnimationWrapper *group; + ParallelAnimationWrapper group; QmlTransitionManager *endState; void init() { - group = new ParallelAnimationWrapper; - group->trans = this; + group.trans = this; } void complete() @@ -121,7 +120,7 @@ public: void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a) { QmlConcreteList::append(a); - parent->group->addAnimation(a->qtAnimation()); + parent->group.addAnimation(a->qtAnimation()); } void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) @@ -146,14 +145,12 @@ QmlTransition::QmlTransition(QObject *parent) QmlTransition::~QmlTransition() { - Q_D(QmlTransition); - delete d->group; } void QmlTransition::stop() { Q_D(QmlTransition); - d->group->stop(); + d->group.stop(); } void QmlTransition::setReversed(bool r) @@ -179,8 +176,8 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions, } d->endState = endState; - d->group->setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); - d->group->start(); + d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward); + d->group.start(); } /*! -- cgit v0.12