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::cast_to checks provided object for nullptr #794

Merged
merged 1 commit into from
Jul 26, 2022
Merged

Object::cast_to checks provided object for nullptr #794

merged 1 commit into from
Jul 26, 2022

Conversation

DNKpp
Copy link
Contributor

@DNKpp DNKpp commented Jul 25, 2022

As Objec::cast_to is merely a dynamic_cast, it shouldn't fail on nullptr. As the provided argument gets dereferenced right away, we have to make the initial check. As I'm fairly new to the godot scene, I do not have much insights into the code base. Perhaps there is a more elegant solution to the problem, but I won't find it right now.

Nevertheless, this fix also fixes calls to Node::get_node<T> when no Node with the given name can be found (and probably even more other parts).

@Calinou Calinou added the bug This has been identified as a bug label Jul 25, 2022
Copy link
Contributor

@Faless Faless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, and in line with what we do in godot. 👍

@Faless Faless merged commit dcd4460 into godotengine:master Jul 26, 2022
@Faless
Copy link
Contributor

Faless commented Jul 26, 2022

Thanks!

@akien-mga akien-mga added this to the 4.0 milestone Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This has been identified as a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants