summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2018-09-27 21:43:30 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2018-09-28 14:00:57 +0000
commitabb089c9875e055a11121df549962ed71f2ae1d8 (patch)
tree961f9df41411753f5aaaa8d56e8fc9092eefc6ae
parentc7256f90b01ec2433ecd2c5ce44128b8dbf12ec3 (diff)
Fix how we create the key for the AnimationValueChange
The optimization done in e18f3739 got lost due to a last minute change, this change rectifies that mistake. Note that even though the change didn't give the results as initially intended, it was not a regression. Change-Id: I3e24fe0f0339d965f79a8276a9a0b4c7b8e92261 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/runtime/q3dsanimationmanager.cpp20
-rw-r--r--src/runtime/q3dsanimationmanager_p.h2
2 files changed, 10 insertions, 12 deletions
diff --git a/src/runtime/q3dsanimationmanager.cpp b/src/runtime/q3dsanimationmanager.cpp
index 396e325..6a33cae 100644
--- a/src/runtime/q3dsanimationmanager.cpp
+++ b/src/runtime/q3dsanimationmanager.cpp
@@ -57,9 +57,10 @@ public:
: m_target(target),
m_animationManager(manager),
m_property(property),
- m_propertyName(propertyName),
m_type(type),
- m_changeFlag(target->mapChangeFlags({{propertyName}})) { }
+ m_changeFlag(target->mapChangeFlags({{propertyName}})),
+ m_propertyName(propertyName),
+ m_key(::qHash(Q3DSAnimationManager::AnimationValueChange{this}, uint(qGlobalQHashSeed()), true)) { }
void valueChanged(const QVariant &value) override;
@@ -67,24 +68,21 @@ private:
static QVariant stabilizeAnimatedValue(const QVariant &value, QVariant::Type type);
friend class Q3DSAnimationManager;
- friend uint qHash(const Q3DSAnimationManager::AnimationValueChange &, uint);
+ friend uint qHash(const Q3DSAnimationManager::AnimationValueChange &, uint, bool);
friend bool operator==(const Q3DSAnimationManager::AnimationValueChange &, const Q3DSAnimationManager::AnimationValueChange &);
Q3DSGraphObject *m_target;
Q3DSAnimationManager *m_animationManager;
QMetaProperty m_property;
- QString m_propertyName;
QVariant m_value;
QVariant::Type m_type;
int m_changeFlag;
- int m_key = -1;
+ const QString m_propertyName;
+ const uint m_key;
};
void Q3DSAnimationCallback::valueChanged(const QVariant &value)
{
- if (m_key < 0)
- m_key = int(::qHash(Q3DSAnimationManager::AnimationValueChange{this}, uint(qGlobalQHashSeed())));
-
// Do not directly change the value and trigger change notifications.
// Instead, queue up (and compress), and defer to applyChanges() which is
// invoked once per frame.
@@ -583,10 +581,10 @@ void Q3DSAnimationManager::queueChange(const AnimationValueChange &change)
m_changes.insert(change);
}
-uint qHash(const Q3DSAnimationManager::AnimationValueChange &key, uint seed)
+uint qHash(const Q3DSAnimationManager::AnimationValueChange &key, uint seed, bool init)
{
- return (key.cb->m_key < 0) ? ::qHash(QStringLiteral("%1%2").arg(key.cb->m_propertyName).arg(quintptr(key.cb->m_target)), seed)
- : uint(key.cb->m_key);
+ return init ? ::qHash(QStringLiteral("%1%2").arg(key.cb->m_propertyName).arg(quintptr(key.cb->m_target)), seed)
+ : uint(key.cb->m_key);
}
bool operator==(const Q3DSAnimationManager::AnimationValueChange &cl, const Q3DSAnimationManager::AnimationValueChange &cr)
diff --git a/src/runtime/q3dsanimationmanager_p.h b/src/runtime/q3dsanimationmanager_p.h
index db1469b..7a11b41 100644
--- a/src/runtime/q3dsanimationmanager_p.h
+++ b/src/runtime/q3dsanimationmanager_p.h
@@ -80,7 +80,7 @@ private:
friend class Q3DSAnimationCallback;
};
-inline uint qHash(const Q3DSAnimationManager::AnimationValueChange &key, uint seed);
+inline uint qHash(const Q3DSAnimationManager::AnimationValueChange &key, uint seed = 0, bool init = false);
inline bool operator==(const Q3DSAnimationManager::AnimationValueChange &cl,
const Q3DSAnimationManager::AnimationValueChange &cr);