Verify the animation impl type matches the animation ctrl type

This commit is contained in:
Robin Dunn
2020-04-01 12:39:48 -07:00
parent e464453073
commit 606f365ea3
3 changed files with 8 additions and 0 deletions

View File

@@ -41,6 +41,8 @@ class WXDLLIMPEXP_CORE wxAnimationImpl : public wxObject, public wxRefCounter
public: public:
wxAnimationImpl() {} wxAnimationImpl() {}
virtual wxAnimationImplType GetImplType() = 0;
virtual bool IsOk() const = 0; virtual bool IsOk() const = 0;
// can be -1 // can be -1

View File

@@ -24,6 +24,9 @@ class WXDLLIMPEXP_ADV wxAnimationGenericImpl : public wxAnimationImpl
public: public:
wxAnimationGenericImpl() {} wxAnimationGenericImpl() {}
virtual wxAnimationImplType GetImplType() wxOVERRIDE
{ return wxANIMATION_IMPL_TYPE_GENERIC; }
virtual bool IsOk() const wxOVERRIDE virtual bool IsOk() const wxOVERRIDE
{ return m_refData != NULL; } { return m_refData != NULL; }

View File

@@ -335,6 +335,9 @@ void wxGenericAnimationCtrl::SetAnimation(const wxAnimation& animation)
if (IsPlaying()) if (IsPlaying())
Stop(); Stop();
wxCHECK_RET(animation.GetImpl()->GetImplType() == wxANIMATION_IMPL_TYPE_GENERIC,
wxT("incorrect animation implementation type provided") );
// set new animation even if it's wxNullAnimation // set new animation even if it's wxNullAnimation
m_animation = animation; m_animation = animation;
if (!m_animation.IsOk()) if (!m_animation.IsOk())