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.
  • Loading branch information
aaronp64 committed Sep 3, 2024
1 parent 8120e03 commit 7a9acd5
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 @@ -5048,6 +5048,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 7a9acd5

Please sign in to comment.