-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Never duplicate script
with Resource.duplicate()
#65374
Conversation
This PR would fix the same identical bug by adding a flag. #41923 However, it's 2 years old and the flags are reaching their limit. It's worth considering. |
Thanks @Mickeon. I tested the changes and they fix the perplexing |
1f1875d
to
fabe8c0
Compare
Might be worth adding a note in the docs that the script is not being duplicated even if BTW this note: godot/doc/classes/Resource.xml Line 26 in 61021c0
doesn't seem true to me, it looks like this part would handle resursively duplicating subresources: Lines 265 to 269 in 61021c0
And indeed seems like they are being duplicated recusively, simple example: class_name Res
extends Resource
@export var subresource: Resource = null @tool
extends EditorScript
func _run():
var r := Res.new()
r.subresource = Res.new()
r.subresource.subresource = Res.new()
print_res_info(r)
print_res_info(r.duplicate(false))
print_res_info(r.duplicate(true))
func print_res_info(r) -> void:
print("r=%s r.subresource=%s r.subresource.subresource=%s" % [r, r.subresource, r.subresource.subresource]) Output:
So even in 3.x subresources are being duplicated recursively... 🤔 That note was added in #40210, not sure what were the exact reason (haven't read #30385 deeply) but it should be corrected too (might be done in a seperate PR though if you want to keep things simple here @Mickeon). |
And I'm not sure if not duplicating script is always desired, someone else would need to confirm/deny it. If there are situations where duplicating it is wanted then probably |
Should do, can do.
I could do it here, but I struggle to understand what is incorrect about it, at least at the time of writing this.
In those cases, wouldn't it be possible to write something like |
The entire description honestly smells, I think the behaviour should be re-analysed and the description rewritten. For now I'm just going to add another note to it in this PR. |
fabe8c0
to
d916d0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, we discussed it in a PR meeting and couldn't find a reason why we'd want to duplicate Script resources.
We just need to decide if we prefer this approach or the one in #41923, which introduces PROPERTY_USAGE_ALWAYS_SHARE_ON_DUPLICATE
as pendant to the existing PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE
.
d916d0f
to
7f61d40
Compare
7f61d40
to
1450441
Compare
PR review meeting: we prefer the implementation in #41923. Thanks for contributing! |
Fix #58031.
Excludes the
script
property of a Resource from being ever duplicated. This doesn't mean that a Script resource cannot ever be duplicated, however.