Explorar el Código

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)
jmb462 hace 4 años
padre
commit
ae8019a7f6
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      scene/2d/animated_sprite.cpp

+ 1 - 1
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) {