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

void push_unhandled_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
#endif 
	void set_disable_input(bool p_disable);
	bool is_input_disabled() const;
	Vector2 get_mouse_position() const;
	void warp_mouse(const Vector2 &p_position);
	virtual void update_mouse_cursor_state();
	void set_physics_object_picking(bool p_enable);
	bool get_physics_object_picking();
	void set_physics_object_picking_sort(bool p_enable);
	bool get_physics_object_picking_sort();
	Variant gui_get_drag_data() const;
	void gui_reset_canvas_sort_index();
	int gui_get_canvas_sort_index();
	void gui_release_focus();
	Control *gui_get_focus_owner() const;
	PackedStringArray get_configuration_warnings() const override;
	void set_debug_draw(DebugDraw p_debug_draw);
	DebugDraw get_debug_draw() const;
	int get_render_info(RenderInfoType p_type, RenderInfo p_info);
	void set_snap_controls_to_pixels(bool p_enable);
	bool is_snap_controls_to_pixels_enabled() const;
	void set_snap_2d_transforms_to_pixel(bool p_enable);
	bool is_snap_2d_transforms_to_pixel_enabled() const;
	void set_snap_2d_vertices_to_pixel(bool p_enable);
	bool is_snap_2d_vertices_to_pixel_enabled() const;
	void set_input_as_handled();
	bool is_input_handled() const;
	void set_handle_input_locally(bool p_enable);
	bool is_handling_input_locally() const;