Skip to content
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

Unable to connect signal to callback with binds if script extends another with callback defined - 4.3 beta 1 #93438

Closed
bhottovy opened this issue Jun 21, 2024 · 1 comment · Fixed by #93452

Comments

@bhottovy
Copy link

Tested versions

  • Reproducible in 4.3.beta1 (mono) and 4.3.beta2 (mono)

System information

Windows 11 -Godot v4.3.beta1 - Vulkan (Forward+)

Issue description

After updating to 4.3 beta 1 I have had issues with scenes that have connections including binds throwing several errors and deleting all these connections in the editor. This occurs if the script with the callback method extends another script that has the callback defined but is not defined in itself. If the connection does not have any binds it works fine but once any are added it breaks.

I believe this is relevant to #91630 that appears to have fixed the problems in base scripts but not in extended classes.

Steps to reproduce

  1. Create a script/class with the desired callback and input values.
  2. Create a new script that extends the previous script.
  3. Add the extended script to a node.
  4. On this node (or any other node) connect one of the signals to this node's callback.
  5. If the signal is connected to the callback without any binds it is connected successfully.
    image
    image
  6. If the signal is connected to the callback with one or more binds the connection is deleted and the error
    "Cannot connect to 'signal': the provided callable is not valid: Node(Node.cs)::_Callback" is thrown.
    image
    image

Minimal reproduction project (MRP)

callable_mrp.zip

To use the MRP open "node.tscn", add a connection to any signal on this node to itself with the "_OnTest" callable and add any bind. If a bind is not added it works correctly.

@raulsntos
Copy link
Member

When connecting to a signal, the created Callable is invalid (is_valid() returns false) because when checking target->has_method() it returns false.

This is calling Object::has_method which calls ScriptInstance::has_method. In this case the script instance is a PlaceHolderScriptInstance because the script is not marked as tool.

The PlaceHolderScriptInstance::has_method implementation only calls Script::has_method on the corresponding script (GDScript or CSharpScript), but doesn't iterate the base scripts. This is unlike the GDScriptInstance::has_method and CSharpScriptInstance::has_method implementations that do iterate the base scripts.

So I think PlaceHolderScriptInstance::has_method should be fixed to iterate the base scripts, like the GDScriptInstance and CSharpScriptInstance implementations do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Unassessed
Development

Successfully merging a pull request may close this issue.

3 participants