Fix crash on calling play() in a uninitialized AnimatedSprite2D

When AnimatedSprite2D::play() was called before SpriteFrames has been initialized, a crach occurred (issue #46013).

Modification : An error message on null check test has been added to prevent crash.

Fix #46013.

(cherry picked from commit 324ab63844)
This commit is contained in:
jmb462 2021-03-16 17:28:16 +01:00 committed by Rémi Verschelde
parent e8d0089901
commit ae8019a7f6
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -605,7 +605,7 @@ bool AnimatedSprite::_is_playing() const {
}
void AnimatedSprite::play(const StringName &p_animation, const bool p_backwards) {
ERR_FAIL_COND_MSG(!frames.is_valid(), "Can't play AnimatedSprite without a valid SpriteFrames resource.");
backwards = p_backwards;
if (p_animation) {