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

Setter called twice if script is extended in instance #101102

Open
KoBeWi opened this issue Jan 3, 2025 · 1 comment
Open

Setter called twice if script is extended in instance #101102

KoBeWi opened this issue Jan 3, 2025 · 1 comment

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Jan 3, 2025

Tested versions

4.4 dev7 and earlier

System information

W10

Issue description

Given this simple script:

extends Node

@export var skin: String:
	set(s):
		print(">", s)
		skin = s

There are cases when the setter will run twice (as evident by double print). This happens when you attach the script to a node and save as scene, then instantiate the scene in another scene, set the property to a different value in the inspector and extend the script. When you run the scene, the setter will be called with the default value and then your exported value.

Steps to reproduce

Run MRP.

Minimal reproduction project (MRP)

SetterBug.zip

@KoBeWi KoBeWi changed the title Setter called twice if script is overriden in instance Setter called twice if script is extended in instance Jan 4, 2025
@github-project-automation github-project-automation bot moved this to For team assessment in GDScript Issue Triage Jan 4, 2025
@AlbePie
Copy link

AlbePie commented Jan 6, 2025

I'm not sure about this, but I think this is an intended behavior. Godot first loads the instanced scene without overrides, which causes the first print, and then applies the override, causing the second print. Again, this is only my hypothesis, it's possible that it is not intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: For team assessment
Development

No branches or pull requests

2 participants