### Godot version

v4.1.stable.mono.official [970459615]

### System information

Godot v4.1.stable.mono - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3090 (NVIDIA; 31.0.15.3640)

### Issue description

With the following scene structure:

- Containing Scene
    - Main 3D Scene
    - Subviewport
        - Another 3D Scene
    - UI control container
        - TextureButton referencing the Subviewport via a ViewportTexture

If the containing scene is itself instanced as a child of another scene within the project, and that other scene is open, closing and re-opening the containing scene will generate several errors of the form `scene/main/viewport.cpp:143 - Viewport Texture must be set to use it.` If the button is visible, the editor will also generate infinite errors of the form

```
Texture (binding: 0) should provide one ID referencing a texture (IDs provided: 0).
drivers/vulkan/rendering_device_vulkan.cpp:7208 - Condition "!uniform_set" is true.
```

Additionally, the TextureButtons will not display the viewport contents.

These errors do not appear, and the TextureButtons will display correctly, if the containing scene is not instanced in another scene in the project, or if the scene in which the containing scene is instanced is not currently open.

May (?) be related to #66247 and/or #69469.

### Steps to reproduce

1. Reproduce the scene structure as described above, or open the attached MRP
2. If the scene instancing the containing scene (`main.tscn` in the attached MRP) is not open, open it
3. If the subviewport/button's containing scene (`game_screen.tscn` in the attached MRP) is not open, open it
4. Close the containing scene
5. Open the containing scene
6. If necessary, select a UI control node to make the button visible.

### Minimal reproduction project

`game_screen.tscn` is the containing scene for the Subviewport and TextureButton. `game_screen.tscn` is instanced as a child of `main.tscn` in `SubviewportBug.zip`. Closing and reopening `game_scene.tscn` in the version from `SubviewportBug.zip` generates errors as described above, until the editor is restarted or an entirely new ViewportTexture is assigned to the button.

In `SubviewportBugNoError.zip`, `game_screen.tscn` is not instanced as a child of any other scene. Closing and reopening `game_scene.tscn` in this version does not generate errors.

Alternatively, close `main.tscn` in the `SubviewportBug.zip` version, and closing and reopening `game_scene.tscn` will not generate errors.

[SubviewportBug.zip](https://github.com/godotengine/godot/files/11986495/SubviewportBug.zip)
[SubviewportBugNoError.zip](https://github.com/godotengine/godot/files/11986496/SubviewportBugNoError.zip)

if (gui.mouse_focus == p_control) {
		gui.mouse_focus = nullptr;
		gui.forced_mouse_focus = false;
		gui.mouse_focus_mask.clear();
	}
	if (gui.last_mouse_focus == p_control) {
		gui.last_mouse_focus = nullptr;
	}
	if (gui.key_focus == p_control) {
		gui.key_focus = nullptr;
	}
	if (gui.mouse_over == p_control) {
		_drop_mouse_over();
	}
	if (gui.drag_mouse_over == p_control) {
		gui.drag_mouse_over = nullptr;
	}
	if (gui.tooltip_control == p_control) {
		gui.tooltip_control = nullptr;
	}
}
Window *Viewport::get_base_window() const {