1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Editor: Fix multi-instance behaviour with embedded game view

Closes #107066
This commit is contained in:
Stuart Carnie
2025-06-06 07:34:49 +10:00
parent 5dd76968d8
commit afd82d7cb3
3 changed files with 8 additions and 4 deletions

View File

@@ -794,11 +794,8 @@ void GameView::_update_floating_window_settings() {
} }
void GameView::_attach_script_debugger() { void GameView::_attach_script_debugger() {
if (embedded_script_debugger) {
_detach_script_debugger(); _detach_script_debugger();
}
embedded_script_debugger = nullptr;
int i = 0; int i = 0;
while (ScriptEditorDebugger *script_debugger = EditorDebuggerNode::get_singleton()->get_debugger(i)) { while (ScriptEditorDebugger *script_debugger = EditorDebuggerNode::get_singleton()->get_debugger(i)) {
if (script_debugger->is_session_active() && script_debugger->get_remote_pid() == embedded_process->get_embedded_pid()) { if (script_debugger->is_session_active() && script_debugger->get_remote_pid() == embedded_process->get_embedded_pid()) {
@@ -824,6 +821,7 @@ void GameView::_detach_script_debugger() {
embedded_script_debugger->disconnect("embed_shortcut_requested", callable_mp(this, &GameView::_handle_shortcut_requested)); embedded_script_debugger->disconnect("embed_shortcut_requested", callable_mp(this, &GameView::_handle_shortcut_requested));
embedded_script_debugger = nullptr; embedded_script_debugger = nullptr;
} }
embedded_process->set_script_debugger(nullptr);
} }
void GameView::_remote_window_title_changed(String title) { void GameView::_remote_window_title_changed(String title) {
@@ -913,6 +911,10 @@ void GameView::_update_arguments_for_instance(int p_idx, List<String> &r_argumen
} }
void GameView::_window_close_request() { void GameView::_window_close_request() {
if (window_wrapper->get_window_enabled()) {
window_wrapper->set_window_enabled(false);
}
// Before the parent window closed, we close the embedded game. That prevents // 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. // 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())) { if (EditorRunBar::get_singleton()->is_playing() && (embedded_process->is_embedding_completed() || embedded_process->is_embedding_in_progress())) {

View File

@@ -62,6 +62,7 @@ class EmbeddedProcessMacOS final : public EmbeddedProcessBase {
IN_PROGRESS, IN_PROGRESS,
COMPLETED, COMPLETED,
FAILED, FAILED,
CLOSED,
}; };
DisplayServerMacOS *ds = nullptr; DisplayServerMacOS *ds = nullptr;

View File

@@ -128,6 +128,7 @@ void EmbeddedProcessMacOS::request_close() {
if (current_process_id != 0 && is_embedding_completed()) { if (current_process_id != 0 && is_embedding_completed()) {
script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_CLOSE_REQUEST }); script_debugger->send_message("embed:win_event", { DisplayServer::WINDOW_EVENT_CLOSE_REQUEST });
} }
embedding_state = EmbeddingState::CLOSED;
} }
void EmbeddedProcessMacOS::display_state_changed() { void EmbeddedProcessMacOS::display_state_changed() {