From 606f365ea370ad0df86a18c0ef82b20a28f0c2d0 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 1 Apr 2020 12:39:48 -0700 Subject: [PATCH] Verify the animation impl type matches the animation ctrl type --- include/wx/animate.h | 2 ++ include/wx/generic/animate.h | 3 +++ src/generic/animateg.cpp | 3 +++ 3 files changed, 8 insertions(+) diff --git a/include/wx/animate.h b/include/wx/animate.h index 12cc2ed039..1246dab276 100644 --- a/include/wx/animate.h +++ b/include/wx/animate.h @@ -41,6 +41,8 @@ class WXDLLIMPEXP_CORE wxAnimationImpl : public wxObject, public wxRefCounter public: wxAnimationImpl() {} + virtual wxAnimationImplType GetImplType() = 0; + virtual bool IsOk() const = 0; // can be -1 diff --git a/include/wx/generic/animate.h b/include/wx/generic/animate.h index 90ecdd7486..b2c3d2eed2 100644 --- a/include/wx/generic/animate.h +++ b/include/wx/generic/animate.h @@ -24,6 +24,9 @@ class WXDLLIMPEXP_ADV wxAnimationGenericImpl : public wxAnimationImpl public: wxAnimationGenericImpl() {} + virtual wxAnimationImplType GetImplType() wxOVERRIDE + { return wxANIMATION_IMPL_TYPE_GENERIC; } + virtual bool IsOk() const wxOVERRIDE { return m_refData != NULL; } diff --git a/src/generic/animateg.cpp b/src/generic/animateg.cpp index 648407111d..104bead684 100644 --- a/src/generic/animateg.cpp +++ b/src/generic/animateg.cpp @@ -335,6 +335,9 @@ void wxGenericAnimationCtrl::SetAnimation(const wxAnimation& animation) if (IsPlaying()) Stop(); + wxCHECK_RET(animation.GetImpl()->GetImplType() == wxANIMATION_IMPL_TYPE_GENERIC, + wxT("incorrect animation implementation type provided") ); + // set new animation even if it's wxNullAnimation m_animation = animation; if (!m_animation.IsOk())