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