### Godot version

 v4.0.beta11.official.91713ced8

### System information

macOS 12.6.1 Monterey, Apple M1 Pro

### Issue description

After reopening scenes with Sprite2D and trying to edit the region of the sprite again the Godot app crashed.

### Steps to reproduce

1. Open scene node_2d in the project files
2. Go to Sprite2D and click on edit region, pop up should show
3. Close the popup and close the scene with X on the tab
4. Reopen the scene, go to Sprite2D and click on Edit region
5. Godot should crash

### Minimal reproduction project

[region_crash.zip](https://github.com/godotengine/godot/files/10400566/region_crash.zip)

edited_margin = 3;
						prev_margin = margins[3];
					}
					if (edited_margin >= 0) {
						drag_from = mb->get_position();
						drag = true;
					}
				}
				if (edited_margin < 0 && snap_mode == SNAP_AUTOSLICE) {
					Vector2 point = mtx.affine_inverse().xform(mb->get_position());
					for (const Rect2 &E : autoslice_cache) {
						if (E.has_point(point)) {
							rect = E;
							if (Input::get_singleton()->is_key_pressed(Key::CTRL) && !(Input::get_singleton()->is_key_pressed(Key(Key::SHIFT | Key::ALT)))) {
								Rect2 r;
								if (atlas_tex.is_valid()) {
									r = atlas_tex->get_region();
								} else if (node_sprite_2d) {
									r = node_sprite_2d->get_region_rect();
								} else if (node_sprite_3d) {
									r = node_sprite_3d->get_region_rect();
								} else if (node_ninepatch) {
									r = node_ninepatch->get_region_rect();
								} else if (obj_styleBox.is_valid()) {
									r = obj_styleBox->get_region_rect();
								}
								rect.expand_to(r.position);
								rect.expand_to(r.get_end());
							}
							undo_redo->create_action(TTR("Set Region Rect"));