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