浏览代码

Fix `KeyValuePairAt` memory leak

(cherry picked from commit 1fdfc379b6230b7d3dac4f22c846c45e93cd596d)
Raul Santos 3 年之前
父节点
当前提交
172f66a40e
共有 1 个文件被更改,包括 2 次插入4 次删除
  1. 2 4
      modules/mono/glue/collections_glue.cpp

+ 2 - 4
modules/mono/glue/collections_glue.cpp

@@ -236,10 +236,8 @@ int32_t godot_icall_Dictionary_KeyValuePairs(Dictionary *ptr, Array **keys, Arra
 }
 
 void godot_icall_Dictionary_KeyValuePairAt(Dictionary *ptr, int index, MonoObject **key, MonoObject **value) {
-	Array *keys = godot_icall_Dictionary_Keys(ptr);
-	Array *values = godot_icall_Dictionary_Values(ptr);
-	*key = GDMonoMarshal::variant_to_mono_object(keys->get(index));
-	*value = GDMonoMarshal::variant_to_mono_object(values->get(index));
+	*key = GDMonoMarshal::variant_to_mono_object(ptr->get_key_at_index(index));
+	*value = GDMonoMarshal::variant_to_mono_object(ptr->get_value_at_index(index));
 }
 
 void godot_icall_Dictionary_Add(Dictionary *ptr, MonoObject *key, MonoObject *value) {