### 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)

node_ninepatch = nullptr;
	obj_styleBox = Ref<StyleBoxTexture>(nullptr);
	atlas_tex = Ref<AtlasTexture>(nullptr);
	preview_tex = Ref<CanvasTexture>(memnew(CanvasTexture));
	snap_step = Vector2(10, 10);
	snap_separation = Vector2(0, 0);
	snap_mode = SNAP_NONE;
	edited_margin = -1;
	drag_index = -1;
	drag = false;
	HBoxContainer *hb_tools = memnew(HBoxContainer);
	vb->add_child(hb_tools);
	hb_tools->add_child(memnew(Label(TTR("Snap Mode:"))));
	snap_mode_button = memnew(OptionButton);
	hb_tools->add_child(snap_mode_button);
	snap_mode_button->add_item(TTR("None"), 0);
	snap_mode_button->add_item(TTR("Pixel Snap"), 1);
	snap_mode_button->add_item(TTR("Grid Snap"), 2);
	snap_mode_button->add_item(TTR("Auto Slice"), 3);
	snap_mode_button->select(0);
	snap_mode_button->connect("item_selected", callable_mp(this, &TextureRegionEditor::_set_snap_mode));
	hb_grid = memnew(HBoxContainer);
	hb_tools->add_child(hb_grid);
	hb_grid->add_child(memnew(VSeparator));
	hb_grid->add_child(memnew(Label(TTR("Offset:"))));
	sb_off_x = memnew(SpinBox);
	sb_off_x->set_min(-256);
	sb_off_x->set_max(256);
	sb_off_x->set_step(1);
	sb_off_x->set_value(snap_offset.x);