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

Add SceneTree.unload_current_scene() #71105

Merged
merged 1 commit into from
Jan 11, 2023

Conversation

reduz
Copy link
Member

@reduz reduz commented Jan 9, 2023

Provides an obvious way to unload the currently loaded scene (which is nowhere to be found in the docs). The SceneTree.change_scene_to() method must now always provide a valid PackedScene.

Fixes #63565.

@reduz reduz requested review from a team as code owners January 9, 2023 11:25
@Zireael07
Copy link
Contributor

Is the unload immediate or like queue_free (a frame later)?

doc/classes/SceneTree.xml Outdated Show resolved Hide resolved
doc/classes/SceneTree.xml Outdated Show resolved Hide resolved
scene/main/scene_tree.cpp Outdated Show resolved Hide resolved
Provides an obvious way to unload the currently loaded scene (which is nowhere to be found in the docs).
The SceneTree.change_scene_to() method must now always provide a valid PackedScene.

Fixes godotengine#63565.
@reduz reduz force-pushed the unload-current-scene branch from 051b5b2 to e5f2c44 Compare January 10, 2023 13:02
@akien-mga akien-mga merged commit baae87e into godotengine:master Jan 11, 2023
@akien-mga
Copy link
Member

Thanks!

Comment on lines +1136 to +1137
Node *new_scene = p_scene->instantiate();
new_scene = p_scene->instantiate();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch memory leak. Fixed in #71459.

Streq pushed a commit to Streq/godot that referenced this pull request Feb 9, 2023
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.

change_scene_to() fails silently when provided a Node
4 participants