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

GDScript: Fix access non-static members in static context #91412

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented May 1, 2024

@dalexeev dalexeev added this to the 4.3 milestone May 1, 2024
@dalexeev dalexeev requested a review from a team as a code owner May 1, 2024 13:50
@dalexeev dalexeev force-pushed the gds-fix-non-static-access-in-static-context branch from bd301e8 to 8122a27 Compare May 1, 2024 16:55
Comment on lines -4049 to +4065
// If the identifier is a member variable (including the native class properties) or a signal, we consider the lambda to be using `self`, so we keep a reference to the current instance.
if (source_is_variable || source_is_signal) {
// If the identifier is a member variable (including the native class properties), member function, or a signal,
// we consider the lambda to be using `self`, so we keep a reference to the current instance.
if (source_is_instance_variable || source_is_instance_function || source_is_signal) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is an "unrelated" change, but I guess it makes sense? At least the tests did not detect regressions, but this is not always a reliable criterion.

Comment on lines +74 to +75
test_static_var_lambda = null
test_non_static_var_lambda = null
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes memory leaks in CI. I'm not sure if this is a bug, but it's probably unrelated to the changes since I've noticed this problem before.

Copy link
Member

Choose a reason for hiding this comment

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

It's a reference cycle. Lambda contains a reference to self which in turn contains a reference to the lambda. Not sure if there's a good way to solve it.

Copy link
Member

@vnen vnen left a comment

Choose a reason for hiding this comment

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

LGTM

@akien-mga akien-mga merged commit 76f642b into godotengine:master May 2, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@dalexeev dalexeev deleted the gds-fix-non-static-access-in-static-context branch May 2, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-static methods can't be referenced as Callables from static methods
3 participants