Skip to content

Commit 8d04657

Browse files
committed
Merge pull request #108692 from m4gr3d/fix_debugger_immediate_disconnect
Fix debugger immediate disconnect
2 parents 9bb9a95 + f713a20 commit 8d04657

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

editor/debugger/editor_debugger_node.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ void EditorDebuggerNode::stop(bool p_force) {
311311

312312
// Also close all debugging sessions.
313313
_for_all(tabs, [&](ScriptEditorDebugger *dbg) {
314-
dbg->_stop_and_notify();
314+
if (dbg->is_session_active()) {
315+
dbg->_stop_and_notify();
316+
}
315317
});
316318
_break_state_changed();
317319
breakpoints.clear();

platform/android/editor/editor_utils_jni.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include "jni_utils.h"
3434

3535
#ifdef TOOLS_ENABLED
36+
#include "editor/debugger/editor_debugger_node.h"
37+
#include "editor/debugger/script_editor_debugger.h"
3638
#include "editor/run/editor_run_bar.h"
3739
#include "main/main.h"
3840
#endif
@@ -53,6 +55,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_EditorUtils_runSc
5355

5456
EditorRunBar *editor_run_bar = EditorRunBar::get_singleton();
5557
if (editor_run_bar != nullptr) {
58+
editor_run_bar->stop_playing();
59+
// Ensure that all ScriptEditorDebugger instances are explicitly stopped.
60+
// If not, a closing instance from the previous run session will trigger `_stop_and_notify()`, in turn causing
61+
// the closure of the ScriptEditorDebugger instances of the run session we're about to launch.
62+
EditorDebuggerNode *dbg_node = EditorDebuggerNode::get_singleton();
63+
if (dbg_node != nullptr) {
64+
for (int i = 0; ScriptEditorDebugger *dbg = dbg_node->get_debugger(i); i++) {
65+
dbg->stop();
66+
}
67+
}
68+
5669
if (scene.is_empty()) {
5770
editor_run_bar->play_main_scene(false);
5871
} else {

0 commit comments

Comments
 (0)