Repository: godot
Issue: Instances of inherited scenes are not updated when changing exported var value on base scene if scene containing them was already open, until editor restart
Labels: bug,topic:editor

### Tested versions

- Reproducible in v4.2.1.stable.official [b09f793f5]

### System information

Godot v4.2.1.stable - Ubuntu 22.04.4 LTS 22.04 - X11 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 860M (nvidia; 535.161.07) - Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz (8 Threads)

### Issue description

**Summary**

Instances of an inherited scene does not immediately refresh when base scene exported var values are changes, if the scene containing the instances was already opened in the editor.

See Steps to reproduce for more explanations along with a step-by-step repro

**Details**

This only occurs with inherited scene instances when changing base scene parameter, not when there is no extra inheritance level.

If the scene containing the instances is closed and you open it *after* the base scene parameter change, the inherited scene instance parameter is correctly updated.

The bad old value is shown with a revert button, showing that the editor is aware that it's not the base value and is overridden. However, this override is only stored in the editor local state, not saved in scene file: VCS will show no change on the scene containing the inherited scene instance.

As a result, closing the editor immediately without saving will "lose" the bad state, and on next editor start, the inherited scene instance will have the correct value.

Reversely, saving the scene with the bad value will "confirm" the bad values and VCS will show a diff containing the bad overrides. From here, you must click the revert button to get the correct values even after editor restart.

So the bad parameter behaves as if pinned, but not exactly since pinned values do auto-save to confirm override as soon as the vase value changes (even if the scene containing instances is closed!).

**Workaround**

Before each base scene change:
- make sure to close the scene containing the inherited scene instances

OR

After each base scene change:
- make sure to check all inherited scene instances and click revert button on all parameters before saving
- OR restart the editor...

### Steps to reproduce

0. Open the demo.tscn in the MWE. It defines the following scene hierarchy:

- BasePrefab (base_prefab.tscn, exported parameter `value = 1`)
  - InheritedPrefab1 (inherited_prefab_1.tscn, inherits from BasePrefab)
  - InheritedPrefab2 (inherited_prefab_2.tscn, inherits from BasePrefab, overrides `value = 2`)

The demo.tscn scene contains an instance of each of them (with no value override).

To reproduce the bug, make sure to **keep demo.tscn open** during the next steps.

Opening inherited_prefab_1.tscn and inherited_prefab_2.tscn in advance doesn't matter, but it's recommended to keep all scenes open from the start to show how those 2 don't have the issue but demo.tscn has it.

In addition, open the MWE Git repo in your VCS and check that the state is clean (nothing to stage). We'll use it later to check the diff.

1. To change a shared value across all inherited scenes, open base_prefab.tscn and change `value` from 1:

![Base prefab: Value = 1](https://github.com/godotengine/godot/assets/1067772/dc690ce4-857a-4a7d-a68a-77a26ee51c74)

to 10:

![Base prefab: Value = 10](https://github.com/godotengine/godot/assets/1067772/4010f02c-db3d-49e4-9aaa-f53ea88ab28b)

and make sure to save the scene.

2. Verify the impact on inherited scenes:

a. Open inherited_prefab_1.tscn:

![image](https://github.com/godotengine/godot/assets/1067772/4eb1782f-3e41-4f9c-97ed-2bc7c3a866d1)

As expected, it has now value = 10 instead of 1.

b. Open inherited_prefab_2.tscn:

![image](https://github.com/godotengine/godot/assets/1067772/ae7d1b06-184b-4070-8022-e41520d74820)

As expected, it still has its overridden value = 2.

3. Verify the impact on the actual demo.tscn containing scene instances:

Switch back to demo.tscn (it should aready be open).

Check BasePrefab:

![image](https://github.com/godotengine/godot/assets/1067772/16d72a4b-32a6-4f05-835c-5c8248011553)

Value is 10 as expected.

Check InheritedPrefab1

![image](https://github.com/godotengine/godot/assets/1067772/07b886ea-0396-4dfa-990d-7f2429cf7bba)

Unexpected: Value is 1 with Revert button instead of 10.

Check InheritedPrefab2

![image](https://github.com/godotengine/godot/assets/1067772/5946023c-dd43-480d-a8af-a0e8a3f84658)

Value is 2 as expected, since the original scene overrides value = 2.

4. Check the VCS diff

![image](https://github.com/godotengine/godot/assets/1067772/7564e46a-5d27-4938-b10e-1961c06f135b)

base_prefab.tscn was changed indeed, but no sign of demo.tscn. This means the bad InheritedPrefab1 instance value override is only stored in local editor state.

From here, we have two possibilities:

5a. Close the editor and restart it. Note how Godot doesn't ask for scene change, as it should for dirty scenes.

Now InheritedPrefab1 instance has fixed value 10:

![image](https://github.com/godotengine/godot/assets/1067772/8258e3b4-0c62-4031-899f-8f9e40742027)

OR

5b. Save the demo.tscn and check VCS:

![image](https://github.com/godotengine/godot/assets/1067772/22806596-a2e3-4b25-8e0d-56142dec0566)

We now "officialized" the bad override.

---

The fact that the bad override is only stored locally, that Godot can close in 5a. without dirty change prompt and that 5b. gives a different result tells me that this is a bug, not by design: the results are different based on whether we save or not, but the editor assumes there is no dirty state to save.

In addition, the bug only occurs for inherited scene instances, not base scene instances, which makes the result inconsistent when working on scene hierarchies (for instance maybe the BasePrefab is not abstract but an actual enemy usable in the game, and the InheritedPrefab1 is just a variant of that enemy, so both could be together in the scene).

### Minimal reproduction project (MRP)

[v4.2.1 - Inherited scene instance keeps old value after base parameter change as if pinned.zip](https://github.com/godotengine/godot/files/14806043/v4.2.1.-.Inherited.scene.instance.keeps.old.value.after.base.parameter.change.as.if.pinned.zip)