### Godot version

621d68e4129e7e343ff21eb3a5f4e8c1d6bbf456

### System information

Windows

### Issue description

Pressing on the OK button of an warning dialog in the editor crashes the godot editor.

The easiest warnings I found for testing are baking an LightmapGI in an unsaved scene (like #74625, but not as the root node) and loading an invalid bus layout in the audio panel.

The crash only happens when using the OK, button to close the dialog, closing it with the X does not trigger a crash.

The problem seems to be that `Viewport::push_input` only works when inside the tree, which is also checked, but closing the dialog removes it from the tree during input handling breaking the rest of the method as the input event is also not marked as handled.

```
ERROR: Condition "!data.tree" is true. Returning: nullptr
   at: Node::get_tree (C:\dir\godot\scene/main/node.h:411)

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.1.dev.mono.custom_build (4412c1d989fd49479b274c05972a2f66487dd1a5)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] mtx_do_lock (D:\a\_work\1\s\src\vctools\crt\github\stl\src\mutex.cpp:88)
[1] SceneTree::_call_input_pause (C:\dir\godot\scene\main\scene_tree.cpp:1148)
[2] Viewport::_push_unhandled_input_internal (C:\dir\godot\scene\main\viewport.cpp:3048)
[3] Viewport::push_input (C:\dir\godot\scene\main\viewport.cpp:3005)
[4] Window::_window_input (C:\dir\godot\scene\main\window.cpp:1467)
[5] Viewport::_sub_windows_forward_input (C:\dir\godot\scene\main\viewport.cpp:2951)
[6] Viewport::push_input (C:\dir\godot\scene\main\viewport.cpp:2981)
[7] Window::_window_input (C:\dir\godot\scene\main\window.cpp:1467)
[8] CallableCustomMethodPointer<Window,Ref<InputEvent> const &>::call (C:\dir\godot\core\object\callable_method_pointer.h:104)
[9] Callable::callp (C:\dir\godot_3\core\variant\callable.cpp:51)
[10] DisplayServerWindows::_dispatch_input_event (C:\dir\godot\platform\windows\display_server_windows.cpp:2369)
[11] Input::_parse_input_event_impl (C:\dir\godot_3\core\input\input.cpp:708)
[12] Input::flush_buffered_events (C:\dir\godot_3\core\input\input.cpp:967)
[13] DisplayServerWindows::process_events (C:\dir\godot\platform\windows\display_server_windows.cpp:2063)
[14] OS_Windows::run (C:\dir\godot\platform\windows\os_windows.cpp:1478)
[15] widechar_main (C:\dir\godot\platform\windows\godot_windows.cpp:181)
[16] _main (C:\dir\godot\platform\windows\godot_windows.cpp:205)
[17] main (C:\dir\godot\platform\windows\godot_windows.cpp:217)
[18] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[19] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================
```

(This is the unrelated crash mentioned https://github.com/godotengine/godot/pull/77751#pullrequestreview-1456392218)

Apparently did not happen on 9b9bb418cb1137e69b5131ec9fa7b41c0396db28 (https://github.com/godotengine/godot/issues/74625#issuecomment-1462867707)

### Steps to reproduce

Trigger any warning dialog in the editor.

1. Open the attached project
2. Click OK on the Dialog that pops up after loading

### Minimal reproduction project

[Test_77752.zip](https://github.com/godotengine/godot/files/11630679/Test_77752.zip) (yes it is just a project.godot and nothing else)

parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
					parent_visible = nullptr;
				}
			}
		} break;
		case NOTIFICATION_THEME_CHANGED: {
			bg_panel->add_theme_style_override("panel", theme_cache.panel_style);
			child_controls_changed();
			if (is_visible()) {
				_update_child_rects();
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {
			if (parent_visible) {
				parent_visible->disconnect("focus_entered", callable_mp(this, &AcceptDialog::_parent_focused));
				parent_visible = nullptr;
			}
		} break;
		case NOTIFICATION_READY:
		case NOTIFICATION_WM_SIZE_CHANGED: {
			if (is_visible()) {
				_update_child_rects();
			}
		} break;
		case NOTIFICATION_WM_CLOSE_REQUEST: {
			_cancel_pressed();
		} break;
	}
}
void AcceptDialog::_text_submitted(const String &p_text) {