Fix switch to GameView when closing game window

This commit is contained in:
xuhuisheng
2025-10-19 13:30:04 +08:00
committed by Rémi Verschelde
parent 8dcf5b4eaf
commit 75446fc4d0

View File

@@ -1160,6 +1160,9 @@ void GameView::_update_arguments_for_instance(int p_idx, List<String> &r_argumen
void GameView::_window_close_request() {
if (window_wrapper->get_window_enabled()) {
// Stop the embedded process timer before closing the window wrapper,
// so the signal to focus EDITOR_GAME isn't sent when the window is not enabled.
embedded_process->reset();
window_wrapper->set_window_enabled(false);
}
@@ -1169,7 +1172,6 @@ void GameView::_window_close_request() {
// When the embedding is not complete, we need to kill the process.
// If the game is paused, the close request will not be processed by the game, so it's better to kill the process.
if (paused || embedded_process->is_embedding_in_progress()) {
embedded_process->reset();
// Call deferred to prevent the _stop_pressed callback to be executed before the wrapper window
// actually closes.
callable_mp(EditorRunBar::get_singleton(), &EditorRunBar::stop_playing).call_deferred();