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

Don't call parent _get_property_list when a class doesn't define it (for internal binding). #1184

Merged

Conversation

Zylann
Copy link
Collaborator

@Zylann Zylann commented Jul 20, 2023

Fixes part of #1183
Related to godotengine/godot#79683, the pair fixes #1183 completely.

Godot is already supposed to call _get_property_list of parent classes, so the binding function (get_property_list_bind) must really only return procedural properties of the class it belongs to, and not parent or child classes, just like core does.
So in fact, it is possible to simply pass null to Godot when _get_property_list is not defined in the class.

I also found out a few members of Wrapped weren't necessary, and was able to move some of the code away from the GDCLASS macro.

I believe there is a way to also not need plist_owned inside Wrapped, maybe storing it in a thread_local, which would also fix potential issues if get_property_list is called from multiple threads. Maybe it even allows to move more things away from the macro, but I haven't gone to that extent in this PR.

There is also an issue with GDExtensionClassFreePropertyList: it is pretty much the "free" for the non-const pointer returned by GDExtensionClassGetPropertyList, but it receives the pointer as const, so it can't be freed without const_cast, looks like an oversight.

@Zylann Zylann requested a review from a team as a code owner July 20, 2023 20:49
@Zylann Zylann changed the title Don't call parent _get_property_list when a class doesn't define it. Don't call parent _get_property_list when a class doesn't define it (for internal binding). Jul 20, 2023
@Calinou Calinou added bug This has been identified as a bug topic:gdextension This relates to the new Godot 4 extension implementation labels Jul 20, 2023
Copy link
Collaborator

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

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

Thanks!

These changes look great to me, and worked fine in my testing. :-) Only the one minor note about the namespace for the new helper functions.

include/godot_cpp/classes/wrapped.hpp Show resolved Hide resolved
@Zylann Zylann force-pushed the fix_get_property_list_calling_parent branch from 71b22e8 to 2861611 Compare July 26, 2023 19:10
Godot is already supposed to call _get_property_list of parent classes,
so this binding function must really only return procedural properties of
the class it belongs to, and not parent or child classes.
@Zylann Zylann force-pushed the fix_get_property_list_calling_parent branch from 2861611 to baf0b9e Compare July 26, 2023 19:12
@dsnopek dsnopek merged commit 1d49bef into godotengine:master Jul 26, 2023
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 topic:gdextension This relates to the new Godot 4 extension implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_get_property_list of parent classes is never called
3 participants