From c313312ff5301bb6537bbe7187a40fff20726850 Mon Sep 17 00:00:00 2001 From: huisedenanhai Date: Sat, 20 May 2023 20:39:59 +0800 Subject: [PATCH] CSharpScript should not own method infos of the base class --- modules/mono/csharp_script.cpp | 9 +-------- .../GodotSharp/Core/Bridge/ScriptManagerBridge.cs | 8 +++----- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index ff2ca9f0ce4e..1b1cd3ae4a2b 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1596,14 +1596,7 @@ void CSharpInstance::get_method_list(List *p_list) const { return; } - const CSharpScript *top = script.ptr(); - while (top != nullptr) { - for (const CSharpScript::CSharpMethodInfo &E : top->methods) { - p_list->push_back(E.method_info); - } - - top = top->base_script.ptr(); - } + script->get_script_method_list(p_list); } bool CSharpInstance::has_method(const StringName &p_method) const { diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs index 1b23276bbd7e..a501f73daaae 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/ScriptManagerBridge.cs @@ -804,11 +804,11 @@ namespace Godot.Bridge using var methods = new Collections.Array(); Type? top = scriptType; - Type native = GodotObject.InternalGetClassNativeBase(top); + Type native = GodotObject.InternalGetClassNativeBase(scriptType); - while (top != null && top != native) + if (scriptType != null && scriptType != native) { - var methodList = GetMethodListForType(top); + var methodList = GetMethodListForType(scriptType); if (methodList != null) { @@ -859,8 +859,6 @@ namespace Godot.Bridge methods.Add(methodInfo); } } - - top = top.BaseType; } *outMethodsDest = NativeFuncs.godotsharp_array_new_copy(