diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 772b259a632..1200787ff3f 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -311,7 +311,9 @@ void EditorDebuggerNode::stop(bool p_force) { // Also close all debugging sessions. _for_all(tabs, [&](ScriptEditorDebugger *dbg) { - dbg->_stop_and_notify(); + if (dbg->is_session_active()) { + dbg->_stop_and_notify(); + } }); _break_state_changed(); breakpoints.clear(); diff --git a/platform/android/editor/editor_utils_jni.cpp b/platform/android/editor/editor_utils_jni.cpp index 747548600e5..e2b6f3b4e9d 100644 --- a/platform/android/editor/editor_utils_jni.cpp +++ b/platform/android/editor/editor_utils_jni.cpp @@ -33,6 +33,8 @@ #include "jni_utils.h" #ifdef TOOLS_ENABLED +#include "editor/debugger/editor_debugger_node.h" +#include "editor/debugger/script_editor_debugger.h" #include "editor/run/editor_run_bar.h" #include "main/main.h" #endif @@ -53,6 +55,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_EditorUtils_runSc EditorRunBar *editor_run_bar = EditorRunBar::get_singleton(); if (editor_run_bar != nullptr) { + editor_run_bar->stop_playing(); + // Ensure that all ScriptEditorDebugger instances are explicitly stopped. + // If not, a closing instance from the previous run session will trigger `_stop_and_notify()`, in turn causing + // the closure of the ScriptEditorDebugger instances of the run session we're about to launch. + EditorDebuggerNode *dbg_node = EditorDebuggerNode::get_singleton(); + if (dbg_node != nullptr) { + for (int i = 0; ScriptEditorDebugger *dbg = dbg_node->get_debugger(i); i++) { + dbg->stop(); + } + } + if (scene.is_empty()) { editor_run_bar->play_main_scene(false); } else {