瀏覽代碼

Merge pull request #69971 from neikeq/csharp-vararg-ret-premature-free

C#: Fix premature free of returned Variant in vararg methods
Rémi Verschelde 2 年之前
父節點
當前提交
b8e1d6585c
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      modules/mono/editor/bindings_generator.cpp

+ 4 - 1
modules/mono/editor/bindings_generator.cpp

@@ -2489,9 +2489,12 @@ Error BindingsGenerator::_generate_cs_native_calls(const InternalCall &p_icall,
 
 			if (!ret_void) {
 				if (return_type->cname != name_cache.type_Variant) {
+					// Usually the return value takes ownership, but in this case the variant is only used
+					// for conversion to another return type. As such, the local variable takes ownership.
 					r_output << "using godot_variant " << C_LOCAL_VARARG_RET " = ";
 				} else {
-					r_output << "using godot_variant " << C_LOCAL_RET " = ";
+					// Variant's [c_out] takes ownership of the variant value
+					r_output << "godot_variant " << C_LOCAL_RET " = ";
 				}
 			}