Skip to content

Commit

Permalink
Fix SubViewport/AudioStreamPlayer2D crash
Browse files Browse the repository at this point in the history
Updated Viewport destructor to remove itself from World2D, to avoid World2D keeping invalid pointers.

Fixes godotengine#89212
  • Loading branch information
aaronp64 committed Apr 24, 2024
1 parent 4bca2d8 commit f66a50d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4971,6 +4971,9 @@ Viewport::~Viewport() {
for (ViewportTexture *E : viewport_textures) {
E->vp = nullptr;
}
if (world_2d.is_valid()) {
world_2d->remove_viewport(this);
}
ERR_FAIL_NULL(RenderingServer::get_singleton());
RenderingServer::get_singleton()->free(viewport);
}
Expand Down

0 comments on commit f66a50d

Please sign in to comment.