diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 2d30ea345de5..62805359870b 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -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); }