From ae8019a7f694985e61c8a5fd2cb65a40dc13aa07 Mon Sep 17 00:00:00 2001 From: jmb462 Date: Tue, 16 Mar 2021 17:28:16 +0100 Subject: [PATCH] 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 324ab63844e2c42024e9fb7f8fdde234330f1bad) --- scene/2d/animated_sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 780d5254fe..d683e6f50f 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -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) {