Repository: godotengine/godot (language: cpp)

Issue:
Inspector size wrong after switching between scenes
### Tested versions

Godot 4.4.beta2

Not happening in 4.4.dev4

### System information

Fedora Linux 40 (KDE Plasma) on Wayland - X11 display driver, Multi-window

### Issue description

If you scroll down in the inspector and then switch to another scene and back the inspector will not have correct size and scrollbar anymore. 

https://github.com/user-attachments/assets/07da0f72-224b-4f67-a022-2e9f4b4ee85b

you can also see in the video that the scrollbar is wrongly shown in the inspector of the other scene.

### Steps to reproduce

^

### Minimal reproduction project (MRP)

N/A


Discussion / hints:
Can confirm, bisecting
Bisected to https://github.com/godotengine/godot/pull/97415

CC @YeldhamDev 

Fix patch:
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index b79d1243ba6c..97335821374e 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -4138,7 +4138,8 @@ void EditorInspector::expand_revertable() {
 }
 
 void EditorInspector::set_scroll_offset(int p_offset) {
-	set_v_scroll(p_offset);
+	// This can be called before the container finishes sorting its children, so defer it.
+	callable_mp((ScrollContainer *)this, &ScrollContainer::set_v_scroll).call_deferred(p_offset);
 }
 
 int EditorInspector::get_scroll_offset() const {


Test patch: