stop animation, when start/endValues are chaged. Otherwise we will run

into crashes, when value types have not been aligned or can't be aligned
This commit is contained in:
Uwe Rathmann 2022-04-03 16:27:10 +02:00
parent 6728ad2bdc
commit f4a9b15f11
1 changed files with 9 additions and 5 deletions

View File

@ -53,13 +53,13 @@ Q_CONSTRUCTOR_FUNCTION( qskRegisterInterpolator )
#endif #endif
#if defined( Q_CC_CLANG ) #if defined( Q_CC_CLANG )
#if __has_feature( address_sanitizer ) #if __has_feature( address_sanitizer )
#define QSK_DECL_INSANE __attribute__( ( no_sanitize( "undefined" ) ) ) #define QSK_DECL_INSANE __attribute__( ( no_sanitize( "undefined" ) ) )
#endif #endif
#endif #endif
#if !defined( QSK_DECL_INSANE ) #if !defined( QSK_DECL_INSANE )
#define QSK_DECL_INSANE #define QSK_DECL_INSANE
#endif #endif
QSK_DECL_INSANE static inline QVariant qskInterpolate( QSK_DECL_INSANE static inline QVariant qskInterpolate(
@ -112,11 +112,13 @@ QskVariantAnimator::~QskVariantAnimator()
void QskVariantAnimator::setStartValue( const QVariant& value ) void QskVariantAnimator::setStartValue( const QVariant& value )
{ {
stop();
m_startValue = value; m_startValue = value;
} }
void QskVariantAnimator::setEndValue( const QVariant& value ) void QskVariantAnimator::setEndValue( const QVariant& value )
{ {
stop();
m_endValue = value; m_endValue = value;
} }
@ -191,6 +193,8 @@ void QskVariantAnimator::advance( qreal progress )
if ( qFuzzyCompare( progress, 1.0 ) ) if ( qFuzzyCompare( progress, 1.0 ) )
progress = 1.0; progress = 1.0;
Q_ASSERT( qskMetaType( m_startValue ) == qskMetaType( m_endValue ) );
m_currentValue = qskInterpolate( m_interpolator, m_currentValue = qskInterpolate( m_interpolator,
m_startValue, m_endValue, progress ); m_startValue, m_endValue, progress );
} }