-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't get method on CallableCustom "Delegate::Invoke" error when using a lambda function in UndoRedo.AddDoMethod and UndoRedo.AddUndoMethod #90430
Comments
It looks like godot/core/object/undo_redo.cpp Lines 162 to 166 in 83b916b
The error can safely be ignored, but maybe we should implement |
The problem also affects GDScript. func _ready() -> void:
var undo_redo := UndoRedo.new()
var callable: Callable = func() -> void:
pass
undo_redo.add_do_method(callable) I got error: |
This doesn't seem to happen on master. |
I'm sorry! I must have made a mistake. Here's the correct example. var undo_redo := UndoRedo.new()
var value: bool = false
func _ready() -> void:
var do = func() -> void:
value = true
var undo = func() -> void:
value = false
undo_redo.create_action("test")
undo_redo.add_do_method(do)
undo_redo.add_undo_method(undo)
undo_redo.commit_action() |
Since #92350 is being reverted, I think this issue should be reopened(I can reproduce it). |
Tested versions
Tested on v4.2.1.stable.mono.official [b09f793]
System information
Windows 11
Issue description
I'm converting a tool written in C# from a plugin to a runtime tool and have an undo function where a variable is being bound to the
Callable
. In C# this can only be done through a lambda, which is what I'm doing. However, unfortunatelyUndoRedo
'sAddDoMethod()
andAddUndoMethod()
throw the errorCan't get method on CallableCustom "Delegate::Invoke"
which from a quick look in the engine codebase means the function name isn't accessible (which is isn't, it's a lambda function).Note that this is not the same issue as #70026 because it only happens when the
UndoRedo
functions are actually called, but it seems to be similar to #80434 except that that's in GDScript.Steps to reproduce
Use any lambda function when calling
UndoRedo.AddDoMethod
orUndoRedo.AddUndoMethod
, i.e.,UndoRedo.AddUndoMethod(Callable.From(() => GD.Print("Hello World!")))
Minimal reproduction project (MRP)
UndoRedoLambdaBug.zip
Run the project, click the button, check the error log.
The text was updated successfully, but these errors were encountered: