diff options
-rw-r--r-- | src/runtime/q3dsanimationmanager.cpp | 20 | ||||
-rw-r--r-- | src/runtime/q3dsanimationmanager_p.h | 2 |
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); |