diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 8b3a65ca03ae..691c833baaef 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -313,6 +313,17 @@ void EditorDebuggerNode::stop(bool p_force) { inspect_edited_object_wait = false; current_uri.clear(); + // Also close all debugging sessions. + _for_all(tabs, [&](ScriptEditorDebugger *dbg) { + // If the server is also still active, let the debugger notify that it stopped. + // Otherwise, just stop it silently. + if (server.is_valid() || dbg->is_session_active()) { + dbg->_stop_and_notify(); + } else { + dbg->stop(); + } + }); + if (server.is_valid()) { server->stop(); EditorNode::get_log()->add_message("--- Debugging process stopped ---", EditorLog::MSG_TYPE_EDITOR); @@ -325,12 +336,6 @@ void EditorDebuggerNode::stop(bool p_force) { server.unref(); } - // Also close all debugging sessions. - _for_all(tabs, [&](ScriptEditorDebugger *dbg) { - if (dbg->is_session_active()) { - dbg->_stop_and_notify(); - } - }); _break_state_changed(); breakpoints.clear(); EditorUndoRedoManager::get_singleton()->clear_history(EditorUndoRedoManager::REMOTE_HISTORY, false);