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

Adding extra args in the editor "connect a signal to a method" popup when the method is located on a superclass fails #89787

Open
albinaask opened this issue Mar 22, 2024 · 1 comment

Comments

@albinaask
Copy link
Contributor

Tested versions

4.2.1 Stable

System information

Godot v4.2.1.stable - Windows 10.0.22631 - Vulkan (Forward+) - integrated Intel(R) UHD Graphics 620 (Intel Corporation; 30.0.101.1338) - Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz (8 Threads)

Issue description

Just like adding an extra value to a script that is put on a node works, instead directing it onto a method that is in a superclass that is written in GDScript should work.

bild

The picture above shows the setup:

  • A scene that has a Line edit node, this node has a script called 'child' attached.
  • This class has no methods, and extends a class called parent.
  • Parent has a method called 'line_is_edited'
  • Connecting the 'text_changed' via the dialog with no extra arguments with this method works fine, as expected (modifying the method signature, removing the second argument)
  • However, when you add the extra argument, the editor throws the following error:
    bild

Steps to reproduce

  1. Open MRP
  2. Open Scene
  3. Open the 'connect signal' dialog through right clicking the signal 'text_changed' under Node in the inspector
  4. Pick the superclass method through the 'pick' button.
  5. Add an extra bool parameter
  6. Press 'Connect'
  7. Observe error

Minimal reproduction project (MRP)

error project.zip

@azuloo
Copy link
Contributor

azuloo commented Mar 24, 2024

So when you press 'Connect' the following chain of events is happening:

  1. Object::connect() checks if the supplied callable is valid.
  2. The object checks if it has this method (line_is_edited()). In this case the check is against Object::script_instance.
  3. Because you're calling it from the editor and it is not considered the runtime - Object::script_instance is instantiated with PlaceHolderScriptInstance class instance.
  4. PlaceHolderScriptInstance::has_method() calls has_method() on attached script (GDScript in this case).
  5. GDScript::has_method() only checks if it has the supplied method in its own method list and doesn't check its parent methods. And this causes the error.

Marking a script with @tools helps to execute it in editor and thus - fixes the error. But the bound method is not being called. Whether it is intended - requires further investigation.

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

No branches or pull requests

3 participants