Fix SubViewport/AudioStreamPlayer2D crash

Updated Viewport destructor to remove itself from World2D, to avoid World2D keeping invalid pointers.

(cherry picked from commit 7a9acd5aca)
This commit is contained in:
aaronp64 2024-04-24 15:18:56 -04:00 committed by Rémi Verschelde
parent fc5e7c7411
commit a2f64b3c10
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 3 additions and 0 deletions

View File

@ -5032,6 +5032,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);
}