### Godot version

v3.5.stable.official [991bb6ac7]

### System information

Debian 11 - Intel Ivybridge Mobile - GLES3

### Issue description

Pretty much what the title says, the engine freezes when I call Sprite.new() from a method that I previously connected to `joy_connection_changed` signal. No errors are shown.

### Steps to reproduce

1. Run the minimal reproduction project, you will see the Godot icon moving around.
2. Connect or disconnect a gamepad and you will see the icon stops moving due to engine freeze.

### Minimal reproduction project

[minimal-reproduction-project.zip](https://github.com/godotengine/godot/files/11821885/minimal-reproduction-project.zip)

Action &action = action_state[p_action];
	action.pressed_physics_frame = Engine::get_singleton()->get_physics_frames();
	action.pressed_process_frame = Engine::get_singleton()->get_process_frames();
	action.pressed = true;
	action.strength = p_strength;
	action.raw_strength = p_strength;
	action.exact = true;
}
void Input::action_release(const StringName &p_action) {
	
	Action &action = action_state[p_action];
	action.released_physics_frame = Engine::get_singleton()->get_physics_frames();
	action.released_process_frame = Engine::get_singleton()->get_process_frames();
	action.pressed = false;
	action.strength = 0.0f;
	action.raw_strength = 0.0f;
	action.exact = true;
}
void Input::set_emulate_touch_from_mouse(bool p_emulate) {