Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix window wrapper disabling prematurely on close request

AR-DEV-123d331aea3ac
diff --git a/editor/run/game_view_plugin.cpp b/editor/run/game_view_plugin.cpp
index 32fc99aeedf..fabbb8bd900 100644
--- a/editor/run/game_view_plugin.cpp
+++ b/editor/run/game_view_plugin.cpp
@@ -1423,26 +1423,24 @@ 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_timers();
- window_wrapper->set_window_enabled(false);
- }
-
// Before the parent window closed, we close the embedded game. That prevents
// the embedded game to be seen without a parent window for a fraction of second.
if (EditorRunBar::get_singleton()->is_playing() && (embedded_process->is_embedding_completed() || embedded_process->is_embedding_in_progress())) {
// 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()) {
- // Call deferred to prevent the _stop_pressed callback to be executed before the wrapper window
- // actually closes.
+ if (window_wrapper->get_window_enabled()) {
+ embedded_process->reset_timers();
+ window_wrapper->set_window_enabled(false);
+ }
+ // Call deferred to prevent the _stop_pressed callback to be executed before the wrapper window actually closes.
embedded_process->reset();
callable_mp(EditorRunBar::get_singleton(), &EditorRunBar::stop_playing).call_deferred();
} else {
// Try to gracefully close the window. That way, the NOTIFICATION_WM_CLOSE_REQUEST
// notification should be propagated in the game process.
+ // We shouldn't disable the window_wrapper here since if auto_accept_quit is false,
+ // the game will ignore this request and stay alive.
embedded_process->request_close();
}
}