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

bool get_positional_shadow_atlas_16_bits() const;
	void set_positional_shadow_atlas_quadrant_subdiv(int p_quadrant, PositionalShadowAtlasQuadrantSubdiv p_subdiv);
	PositionalShadowAtlasQuadrantSubdiv get_positional_shadow_atlas_quadrant_subdiv(int p_quadrant) const;
	void set_msaa_2d(MSAA p_msaa);
	MSAA get_msaa_2d() const;
	void set_msaa_3d(MSAA p_msaa);
	MSAA get_msaa_3d() const;
	void set_screen_space_aa(ScreenSpaceAA p_screen_space_aa);
	ScreenSpaceAA get_screen_space_aa() const;
	void set_use_taa(bool p_use_taa);
	bool is_using_taa() const;
	void set_scaling_3d_mode(Scaling3DMode p_scaling_3d_mode);
	Scaling3DMode get_scaling_3d_mode() const;
	void set_scaling_3d_scale(float p_scaling_3d_scale);
	float get_scaling_3d_scale() const;
	void set_fsr_sharpness(float p_fsr_sharpness);
	float get_fsr_sharpness() const;
	void set_texture_mipmap_bias(float p_texture_mipmap_bias);
	float get_texture_mipmap_bias() const;
	void set_use_debanding(bool p_use_debanding);
	bool is_using_debanding() const;
	void set_mesh_lod_threshold(float p_pixels);
	float get_mesh_lod_threshold() const;
	void set_use_occlusion_culling(bool p_us_occlusion_culling);
	bool is_using_occlusion_culling() const;
	Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
	Vector2 get_camera_rect_size() const;
	void push_text_input(const String &p_text);
	void push_input(const Ref<InputEvent> &p_event, bool p_local_coords = false);
#ifndef DISABLE_DEPRECATED