### Godot version

v4.0 rc6

### System information

Windows 10

### Issue description

When using a ViewportTexture from a SubViewport on a TextureRect, it throws errors after running the scene once and then switching scenes in the editor.
![Pasted image 20230227212626](https://user-images.githubusercontent.com/44676282/221680047-984fa03e-33d1-4856-9a7f-1700b28423cf.png)


### Steps to reproduce

Run the canvas-scene once.
Switch to another scene in the editor.
Switch back to the canvas-scene

### Minimal reproduction project

[ViewportTextureError.zip](https://github.com/godotengine/godot/files/10844099/ViewportTextureError.zip)

ERR_MAIN_THREAD_GUARD;
	ERR_FAIL_NULL(p_viewport);
	ERR_FAIL_NULL(p_control);
	if (gui.mouse_focus) {
		p_viewport->gui.mouse_focus = p_control;
		p_viewport->gui.mouse_focus_mask = gui.mouse_focus_mask;
		p_viewport->gui.key_focus = p_control;
		p_viewport->gui.forced_mouse_focus = true;
		gui.mouse_focus = nullptr;
		gui.forced_mouse_focus = false;
		gui.mouse_focus_mask.clear();
	}
}
void Viewport::set_sdf_oversize(SDFOversize p_sdf_oversize) {
	ERR_MAIN_THREAD_GUARD;
	ERR_FAIL_INDEX(p_sdf_oversize, SDF_OVERSIZE_MAX);
	sdf_oversize = p_sdf_oversize;
	RS::get_singleton()->viewport_set_sdf_oversize_and_scale(viewport, RS::ViewportSDFOversize(sdf_oversize), RS::ViewportSDFScale(sdf_scale));
}
Viewport::SDFOversize Viewport::get_sdf_oversize() const {
	ERR_READ_THREAD_GUARD_V(SDF_OVERSIZE_100_PERCENT);
	return sdf_oversize;
}
void Viewport::set_sdf_scale(SDFScale p_sdf_scale) {
	ERR_MAIN_THREAD_GUARD;
	ERR_FAIL_INDEX(p_sdf_scale, SDF_SCALE_MAX);
	sdf_scale = p_sdf_scale;
	RS::get_singleton()->viewport_set_sdf_oversize_and_scale(viewport, RS::ViewportSDFOversize(sdf_oversize), RS::ViewportSDFScale(sdf_scale));
}
Viewport::SDFScale Viewport::get_sdf_scale() const {