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

Overridden built-in setter functions are not called when setting a value, even when using self #48843

Closed
Error7Studios opened this issue May 19, 2021 · 2 comments

Comments

@Error7Studios
Copy link

Godot version:

3.3 / 3.3.1

OS/device including version:

Windows 10

Issue description:

Overridden built-in setter functions are not called when setting a value, even when using the self keyword.
(Maybe this is expected, but it doesn't seem right. You have to always remember to call the setter.)

Steps to reproduce:
(See example project)

Minimal reproduction project:

Method Override Bug.zip

@Calinou
Copy link
Member

Calinou commented May 19, 2021

I think this is done by design. You can define a _set() function to create magic setters/getters, but keep in mind this has a performance cost.

@Error7Studios
Copy link
Author

You can define a _set() function to create magic setters/getters

I tried to do that, but this gives me a stack overflow.

func _set(property: String, value) -> bool:
	if get(property) != null:
		match property:
			"bbcode_text":
				"< code here >"
			_:
				pass
		set(property, value)
		return true
	else:
		return false

However, looks like this is already fixed by #47672.
Also, according to #844, setters will get called by default in 4.0, so this will no longer be an issue.

I think this is done by design.

In that case, I'll close this, since 4.0 is almost here and I don't think a change like this will be made for 3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants