Skip to content

Clarify _set/_get description #107823

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

Merged
merged 1 commit into from
Jun 25, 2025
Merged

Clarify _set/_get description #107823

merged 1 commit into from
Jun 25, 2025

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jun 21, 2025

Closes #70205

Note that a property must be present in [method get_property_list], otherwise this method will not be called.

So this note is wrong, but not entirely.

See, _set()/_get() are called when calling set()/get() on an object, with property name that doesn't match any built-in property. So you can do object.get("this_property_totally_exists_trust_me"), and _get() will be called with this property name.

When _get_property_list() matters is when inspecting or serializing the object. The editor/serializer must know that property "exists" and will call set()/get() on whatever is returned by get_property_list(). But if a property is not defined, nothing is stopping you from manually accessing it.

Feel free to suggest how to better convey this information. Or maybe the description is already fine, idk.

@KoBeWi KoBeWi added this to the 4.x milestone Jun 21, 2025
@KoBeWi KoBeWi requested a review from a team as a code owner June 21, 2025 21:05
@Mickeon
Copy link
Member

Mickeon commented Jun 21, 2025

When _get_property_list() matters is when inspecting or serializing the object. The editor/serializer must know that property "exists" and will call set()/get() on whatever is returned by get_property_list(). But if a property is not defined, nothing is stopping you from manually accessing it.

That's crazy because I genuinely could've sworn to have been insisting about this with you and Yuri back in the day before the description was changed with how it is now.

@Mickeon Mickeon added the cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release label Jun 21, 2025
@akien-mga akien-mga modified the milestones: 4.x, 4.5 Jun 25, 2025
@Repiteo Repiteo merged commit e541ed1 into godotengine:master Jun 25, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jun 25, 2025

Thanks!

@KoBeWi KoBeWi deleted the setgettt branch June 25, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release documentation enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Property List _Set not working when field with same name as property exists
4 participants