Open Delsin-Yu opened 5 days ago
Does the error occur if you store the lambda callable in a local or class variable? Maybe GDScript/C#/core loses the last reference and therefore frees the lambda before the callable is called.
@dalexeev
No, neither works.
extends Node
var lambda_field := func(): print("Hello World");
func _ready():
var helper := Helper.new();
var lambda_local := func(): print("Hello World");
helper.CallCallable(lambda_local);
helper.CallCallable(lambda_field);
E 0:00:00:0814 main.gd:8 @ _ready(): Attempt to call callable 'null::null' on a null instance.
<C# Source> /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:160 @ void Godot.NativeInterop.ExceptionUtils.DebugCheckCallError(Godot.NativeInterop.godot_callable&, Godot.NativeInterop.godot_variant**, int, Godot.NativeInterop.godot_variant_call_error)
<Stack Trace> main.gd:8 @ _ready()
E 0:00:00:0815 main.gd:9 @ _ready(): Attempt to call callable 'null::null' on a null instance.
<C# Source> /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/NativeInterop/ExceptionUtils.cs:160 @ void Godot.NativeInterop.ExceptionUtils.DebugCheckCallError(Godot.NativeInterop.godot_callable&, Godot.NativeInterop.godot_variant**, int, Godot.NativeInterop.godot_variant_call_error)
<Stack Trace> main.gd:9 @ _ready()
GodotSharp does not yet support some CallableCustom
, such as GDScriptLambdaCallable
, CallableCustomBind/Unbind
.
same error but happen at calling the CallableCustom
return from GDExtension.
By the way, if i use Variant
but not Callable
to define the variable, csharp can call the CallableCustom::get_as_text
correctly when i print the callable to screen.
So i guess the problem happen at csharp Callable stub.
A tiny GDExtension to make csharp can work well with CallableCustom
.
have tested in windows.
Tested versions
v4.3.stable.mono.official [77dcf97d8]
System information
Godot v4.3.stable.mono - Windows 10.0.17763 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 Ti (NVIDIA; 32.0.15.6109) - AMD Ryzen 9 5900X 12-Core Processor (24 Threads)
Issue description
This is a niche use case, but we should document it if it's not supported.
In C# script, when trying to
Call()
aCallable
that is backed by aGDScript
Lambda Expression
, Godot will produce the following error instead of actually making the call.Steps to reproduce
main.gd
.main.gd
to the root node, and save it to a file.Helper.cs
.Minimal reproduction project (MRP)
main.gd
Helper.cs