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

Fix crash on recovered orphaned nodes. #83604

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

SaracenOne
Copy link
Member

@SaracenOne SaracenOne commented Oct 19, 2023

There are a lot of issues in regards to how Godot recovers nodes from situations where an instanced or inherited node has its overall composition changed, resulting in nodes which might no longer reference a valid parent. However, the most notable issue right now is that if this happens, the scene will become corrupted to the point that it will crash if you attempt to close any scene containining one or more of these orphaned nodes. This is due to the default recover mechanism first extracting the nodes's path, then prepending it to the nodes name between an @ symbol. However, @ is a reserved character, so it sets it with the nocheck name, which subsequently updates the name, but does NOT update its parent's cache, resulting in failure if the node is referenced by path, and subsequently leads to crashes. The scene is essentially corrupted now beyond repair without manual text editing.

While there's a lot more that can be done in regards to recovering scenes with orphaned nodes (I recommend the next step should be constructing dummy nodes to recreate the original path composition as close as possible rather than shoving them in the root), I've changed from the reserved @ symbol to the ~ symbol and used the set_name command which does checks. This should at least now give users an oppertunity to manually repair their scene if nodes become orphaned, but may also be considering an editor-only UID system for scenes, which should more or less completely eliminate scene breakage like this.

Closes #83595

@KoBeWi
Copy link
Member

KoBeWi commented Oct 19, 2023

Using ~ instead of @ makes it less obvious that the path was modified, at a glance (especially when underscores are used). Maybe # would be better?
image
vs
image

@SaracenOne
Copy link
Member Author

Yeah, I agree, # is probably a better symbol. I'll change it.

@SaracenOne SaracenOne force-pushed the orphaned_node_crashfix branch from 9f298d5 to a16cbf6 Compare October 19, 2023 10:16
@akien-mga akien-mga merged commit 37d3cb1 into godotengine:master Oct 20, 2023
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

Renaming nodes in a scene inherited by others can cause corruption and crashes.
3 participants