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

} else {
		vr = window->get_usable_parent_rect();
	}
	if (r.size.x + r.position.x > vr.size.x + vr.position.x) {
		
		r.position.x = gui.tooltip_pos.x - r.size.x - tooltip_offset.x;
		if (r.position.x < vr.position.x) {
			r.position.x = vr.position.x + vr.size.x - r.size.x;
		}
	} else if (r.position.x < vr.position.x) {
		r.position.x = vr.position.x;
	}
	if (r.size.y + r.position.y > vr.size.y + vr.position.y) {
		
		r.position.y = gui.tooltip_pos.y - r.size.y - tooltip_offset.y;
		if (r.position.y < vr.position.y) {
			r.position.y = vr.position.y + vr.size.y - r.size.y;
		}
	} else if (r.position.y < vr.position.y) {
		r.position.y = vr.position.y;
	}
	gui.tooltip_popup->set_position(r.position);
	gui.tooltip_popup->set_size(r.size);
	DisplayServer::WindowID active_popup = DisplayServer::get_singleton()->window_get_active_popup();
	if (active_popup == DisplayServer::INVALID_WINDOW_ID || active_popup == window->get_window_id()) {
		gui.tooltip_popup->show();
	}
	gui.tooltip_popup->child_controls_changed();
}
bool Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_input) {