### 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)

return false;
	}
	Transform2D window_ofs;
	window_ofs.set_origin(-gui.subwindow_focused->get_position());
	Ref<InputEvent> ev = p_event->xformed_by(window_ofs);
	gui.subwindow_focused->_window_input(ev);
	return true;
}
void Viewport::_update_mouse_over() {
	
	
	if (is_attached_in_viewport()) {
		
		return;
	}
	if (get_tree()->get_root()->is_embedding_subwindows() || is_sub_viewport()) {
		
		_update_mouse_over(gui.last_mouse_pos);
	} else {
		
		Window *receiving_window = get_tree()->get_root()->gui.windowmanager_window_over;
		if (!receiving_window) {
			return;
		}
		Vector2 pos = DisplayServer::get_singleton()->mouse_get_position() - receiving_window->get_position();
		pos = receiving_window->get_final_transform().affine_inverse().xform(pos);
		receiving_window->_update_mouse_over(pos);
	}
}
void Viewport::_update_mouse_over(Vector2 p_pos) {