瀏覽代碼

Merge pull request #2088 from KillerJaguar/setter-fix

Fixed variables being set before calling the setter method
Juan Linietsky 10 年之前
父節點
當前提交
68443a649d
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      modules/gdscript/gd_script.cpp

+ 2 - 1
modules/gdscript/gd_script.cpp

@@ -2131,7 +2131,6 @@ bool GDInstance::set(const StringName& p_name, const Variant& p_value) {
 	{
 		const Map<StringName,GDScript::MemberInfo>::Element *E = script->member_indices.find(p_name);
 		if (E) {
-			members[E->get().index]=p_value;
 			if (E->get().setter) {
 				const Variant *val=&p_value;
 				Variant::CallError err;
@@ -2140,6 +2139,8 @@ bool GDInstance::set(const StringName& p_name, const Variant& p_value) {
 					return true; //function exists, call was successful
 				}
 			}
+			else
+				members[E->get().index] = p_value;
 			return true;
 		}
 	}