Repository: godotengine/godot (language: cpp)

Issue:
Tabbing into a different scene while editing SpriteFrames FPS causes the editor to crash
### Tested versions

- Reproducible in Godot 4.3*
- Reproducible in Godot 4.4.1*
- Reproducible in Godot 4.5.dev (latest master)

*Reported by other users in the community.

### System information

Godot v4.5.dev (e585e6a3e) - Windows 11 (build 26100) - Multi-window, 1 monitor - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 3050 Laptop GPU (NVIDIA; 31.0.15.5339) - 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz (12 threads)

### Issue description

Tabbing into a different scene while editing a SpriteFrames resource's FPS causes the editor to crash.

The root cause is a null pointer error on [this line](https://github.com/godotengine/godot/blob/e585e6a3eb35a73aae34786fc18b0824d4050428/editor/plugins/sprite_frames_editor_plugin.cpp#L1304) in SpriteFramesEditor. When changing scenes, the SpriteFrames local to the scene is disposed, causing `Ref<SpriteFrames>` to become null. This happens after SpriteFramesEditor closes, but before it is destroyed.

Note that a similar bug also happens when you try to edit Frame Durations in the same way.

### Steps to reproduce

1. Create two scenes.
2. In the first scene, create an AnimatedSprite2D node, and add a new SpriteFrames resource to it. (Don't save as file)
3. Edit the SpriteFrames resource's FPS, and keep the SpinBox focused. (Don't click anywhere else yet)
4. Tab to the second scene by clicking.
5. Editor crashes.

### Minimal reproduction project (MRP)

N/A


Discussion / hints:

Fix patch:
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 13adc83095a9..ee5e97ea3816 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -1294,6 +1294,10 @@ void SpriteFramesEditor::_animation_speed_resized() {
 }
 
 void SpriteFramesEditor::_animation_speed_changed(double p_value) {
+	if (frames.is_null()) {
+		return;
+	}
+
 	if (updating) {
 		return;
 	}
@@ -1374,6 +1378,10 @@ void SpriteFramesEditor::_frame_list_item_selected(int p_index, bool p_selected)
 }
 
 void SpriteFramesEditor::_frame_duration_changed(double p_value) {
+	if (frames.is_null()) {
+		return;
+	}
+
 	if (updating) {
 		return;
 	}


Test patch: