瀏覽代碼

Merge pull request #74112 from KoBeWi/from_mismatch_to_match

Check for type mismatch in `PropertyTweener.from()`
Rémi Verschelde 2 年之前
父節點
當前提交
dbd76cd1f6
共有 2 個文件被更改,包括 7 次插入0 次删除
  1. 5 0
      scene/animation/tween.cpp
  2. 2 0
      scene/animation/tween.h

+ 5 - 0
scene/animation/tween.cpp

@@ -489,6 +489,11 @@ Tween::Tween(bool p_valid) {
 }
 
 Ref<PropertyTweener> PropertyTweener::from(Variant p_value) {
+	ERR_FAIL_COND_V(tween.is_null(), nullptr);
+	if (!tween->_validate_type_match(p_value, final_val)) {
+		return nullptr;
+	}
+
 	initial_val = p_value;
 	do_continue = false;
 	return this;

+ 2 - 0
scene/animation/tween.h

@@ -61,6 +61,8 @@ class MethodTweener;
 class Tween : public RefCounted {
 	GDCLASS(Tween, RefCounted);
 
+	friend class PropertyTweener;
+
 public:
 	enum TweenProcessMode {
 		TWEEN_PROCESS_PHYSICS,