diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index b1b587d1ff1..8654e317f95 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -129,6 +129,7 @@ void ScriptEditorDebugger::debug_break() { ERR_FAIL_COND(is_breaked()); _put_msg("break", Array()); + _mute_audio_on_break(true); } void ScriptEditorDebugger::debug_continue() { @@ -142,6 +143,7 @@ void ScriptEditorDebugger::debug_continue() { _clear_execution(); _put_msg("continue", Array(), debugging_thread_id); _put_msg("servers:foreground", Array()); + _mute_audio_on_break(false); } void ScriptEditorDebugger::update_tabs() { @@ -324,6 +326,7 @@ void ScriptEditorDebugger::_thread_debug_enter(uint64_t p_thread_id) { ThreadDebugged &td = threads_debugged[p_thread_id]; _set_reason_text(td.error, MESSAGE_ERROR); emit_signal(SNAME("breaked"), true, td.can_debug, td.error, td.has_stackdump); + _mute_audio_on_break(true); if (!td.error.is_empty() && EDITOR_GET("debugger/auto_switch_to_stack_trace")) { tabs->set_current_tab(0); } @@ -395,6 +398,7 @@ void ScriptEditorDebugger::_msg_debug_exit(uint64_t p_thread_id, const Array &p_ _set_reason_text(TTR("Execution resumed."), MESSAGE_SUCCESS); emit_signal(SNAME("breaked"), false, false, "", false); + _mute_audio_on_break(false); _update_buttons_state(); } else { @@ -446,6 +450,11 @@ void ScriptEditorDebugger::_msg_scene_inspect_object(uint64_t p_thread_id, const } #endif // DISABLE_DEPRECATED +void ScriptEditorDebugger::_msg_scene_debug_mute_audio(uint64_t p_thread_id, const Array &p_data) { + ERR_FAIL_COND(p_data.is_empty()); + // This is handled by SceneDebugger, we need to ignore here to not show a warning. +} + void ScriptEditorDebugger::_msg_servers_memory_usage(uint64_t p_thread_id, const Array &p_data) { vmem_tree->clear(); TreeItem *root = vmem_tree->create_item(); @@ -966,6 +975,7 @@ void ScriptEditorDebugger::_init_parse_message_handlers() { #ifndef DISABLE_DEPRECATED parse_message_handlers["scene:inspect_object"] = &ScriptEditorDebugger::_msg_scene_inspect_object; #endif // DISABLE_DEPRECATED + parse_message_handlers["scene:debug_mute_audio"] = &ScriptEditorDebugger::_msg_scene_debug_mute_audio; parse_message_handlers["servers:memory_usage"] = &ScriptEditorDebugger::_msg_servers_memory_usage; parse_message_handlers["servers:drawn"] = &ScriptEditorDebugger::_msg_servers_drawn; parse_message_handlers["stack_dump"] = &ScriptEditorDebugger::_msg_stack_dump; @@ -1628,12 +1638,27 @@ bool ScriptEditorDebugger::get_debug_mute_audio() const { return debug_mute_audio; } -void ScriptEditorDebugger::set_debug_mute_audio(bool p_mute) { +void ScriptEditorDebugger::_send_debug_mute_audio_msg(bool p_mute) { Array msg = { p_mute }; _put_msg("scene:debug_mute_audio", msg); +} + +void ScriptEditorDebugger::set_debug_mute_audio(bool p_mute) { + // Send the message if we want to mute the audio or if it isn't muted already due to a break. + if (p_mute || !audio_muted_on_break) { + _send_debug_mute_audio_msg(p_mute); + } debug_mute_audio = p_mute; } +void ScriptEditorDebugger::_mute_audio_on_break(bool p_mute) { + // Send the message if we want to mute the audio on a break or if it isn't muted already. + if (p_mute || !debug_mute_audio) { + _send_debug_mute_audio_msg(p_mute); + } + audio_muted_on_break = p_mute; +} + CameraOverride ScriptEditorDebugger::get_camera_override() const { return camera_override; } diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index 48d7ce5c3bb..667c4ba7071 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -185,6 +185,9 @@ private: void _select_thread(int p_index); bool debug_mute_audio = false; + bool audio_muted_on_break = false; + void _mute_audio_on_break(bool p_mute); + void _send_debug_mute_audio_msg(bool p_mute); EditorDebuggerNode::CameraOverride camera_override; @@ -206,6 +209,7 @@ private: #ifndef DISABLE_DEPRECATED void _msg_scene_inspect_object(uint64_t p_thread_id, const Array &p_data); #endif // DISABLE_DEPRECATED + void _msg_scene_debug_mute_audio(uint64_t p_thread_id, const Array &p_data); void _msg_servers_memory_usage(uint64_t p_thread_id, const Array &p_data); void _msg_servers_drawn(uint64_t p_thread_id, const Array &p_data); void _msg_stack_dump(uint64_t p_thread_id, const Array &p_data);