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

Object-less callables rejected by Object::connect et al #81887

Closed
maiself opened this issue Sep 18, 2023 · 2 comments · Fixed by #82695
Closed

Object-less callables rejected by Object::connect et al #81887

maiself opened this issue Sep 18, 2023 · 2 comments · Fixed by #82695

Comments

@maiself
Copy link
Contributor

maiself commented Sep 18, 2023

Godot version

master, e3e2528

System information

linux

Issue description

Creating this issue to keep track of something discovered while working working on #79005.

Basically, in some places Godot has checks for object as a way to check if a callable is valid. This seems wrong, especially for custom callables, which may not actually have an associated object. While this doesn't seem to be a problem within the engine itself, it can be a problem for extensions. In my extension I had to use a workaround that creates an object that exists for no reason other than to pass those checks.

Here are some examples of object-less callables being rejected:

I haven't looked to see if there are more cases (I merely searched object.cpp for get_object()).

Original comments from #79005:

Steps to reproduce

N/A

Minimal reproduction project

N/A

@Mickeon
Copy link
Contributor

Mickeon commented Sep 19, 2023

Does simply removing the check for a valid object completely fix this or is there something more going on?

@dsnopek
Copy link
Contributor

dsnopek commented Sep 19, 2023

Does simply removing the check for a valid object completely fix this or is there something more going on?

I think we probably want to replace those checks with callable.is_valid().

The examples in the description seem to be doing their own manual version of a validity check by checking callable.get_object(). However, there's several types of callables, some of which are perfectly valid without objects (and those should have overridden is_valid()).

If I had to guess what happened here, maybe there didn't used to be a is_valid() function (so checking get_object() made sense), but after adding is_valid() some bits of the code didn't get updated?

@dsnopek dsnopek added this to the 4.x milestone Sep 19, 2023
maiself added a commit to maiself/godot that referenced this issue Oct 6, 2023
@akien-mga akien-mga modified the milestones: 4.x, 4.2 Oct 9, 2023
mandryskowski pushed a commit to mandryskowski/godot that referenced this issue Oct 11, 2023
ProbablyWorks pushed a commit to ProbablyWorks/godot that referenced this issue Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants