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

AudioListener2D *get_audio_listener_2d() const;
	Camera2D *get_camera_2d() const;
	void set_as_audio_listener_2d(bool p_enable);
	bool is_audio_listener_2d() const;
	void update_canvas_items();
	Rect2 get_visible_rect() const;
	RID get_viewport_rid() const;
	void set_world_2d(const Ref<World2D> &p_world_2d);
	Ref<World2D> get_world_2d() const;
	Ref<World2D> find_world_2d() const;
	void enable_canvas_transform_override(bool p_enable);
	bool is_canvas_transform_override_enabled() const;
	void set_canvas_transform_override(const Transform2D &p_transform);
	Transform2D get_canvas_transform_override() const;
	void set_canvas_transform(const Transform2D &p_transform);
	Transform2D get_canvas_transform() const;
	void set_global_canvas_transform(const Transform2D &p_transform);
	Transform2D get_global_canvas_transform() const;
	virtual Transform2D get_final_transform() const;
	void assign_next_enabled_camera_2d(const StringName &p_camera_group);
	void gui_set_root_order_dirty();
	void set_transparent_background(bool p_enable);
	bool has_transparent_background() const;
	void set_use_hdr_2d(bool p_enable);
	bool is_using_hdr_2d() const;
	Ref<ViewportTexture> get_texture() const;
	void set_positional_shadow_atlas_size(int p_size);
	int get_positional_shadow_atlas_size() const;
	void set_positional_shadow_atlas_16_bits(bool p_16_bits);