Tween: Add null check for target object

Fixes #45399.

(cherry picked from commit 5b2100d85c)
This commit is contained in:
Christoffer Sundbom 2021-01-25 06:12:49 +01:00 committed by Rémi Verschelde
parent 8a1f8a68fb
commit 3b63467783

View file

@ -1342,6 +1342,9 @@ bool Tween::interpolate_property(Object *p_object, NodePath p_property, Variant
return true;
}
// Check that the target object is valid
ERR_FAIL_COND_V_MSG(p_object == nullptr, false, vformat("The Tween \"%s\"'s target node is `null`. Is the node reference correct?", get_name()));
// Get the property from the node path
p_property = p_property.get_as_property_path();
@ -1365,6 +1368,9 @@ bool Tween::interpolate_method(Object *p_object, StringName p_method, Variant p_
return true;
}
// Check that the target object is valid
ERR_FAIL_COND_V_MSG(p_object == nullptr, false, vformat("The Tween \"%s\"'s target node is `null`. Is the node reference correct?", get_name()));
// Convert any integers into REALs as they are better for interpolation
if (p_initial_val.get_type() == Variant::INT) p_initial_val = p_initial_val.operator real_t();
if (p_final_val.get_type() == Variant::INT) p_final_val = p_final_val.operator real_t();