1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Fix debugger immediate disconnect

Address https://github.com/godotengine/godot/issues/108518
This commit is contained in:
Fredia Huya-Kouadio
2025-07-16 19:47:59 -07:00
parent 71a9948157
commit f713a20c94
2 changed files with 16 additions and 1 deletions

View File

@@ -311,7 +311,9 @@ void EditorDebuggerNode::stop(bool p_force) {
// Also close all debugging sessions. // Also close all debugging sessions.
_for_all(tabs, [&](ScriptEditorDebugger *dbg) { _for_all(tabs, [&](ScriptEditorDebugger *dbg) {
dbg->_stop_and_notify(); if (dbg->is_session_active()) {
dbg->_stop_and_notify();
}
}); });
_break_state_changed(); _break_state_changed();
breakpoints.clear(); breakpoints.clear();

View File

@@ -33,6 +33,8 @@
#include "jni_utils.h" #include "jni_utils.h"
#ifdef TOOLS_ENABLED #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 "editor/run/editor_run_bar.h"
#include "main/main.h" #include "main/main.h"
#endif #endif
@@ -53,6 +55,17 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_editor_utils_EditorUtils_runSc
EditorRunBar *editor_run_bar = EditorRunBar::get_singleton(); EditorRunBar *editor_run_bar = EditorRunBar::get_singleton();
if (editor_run_bar != nullptr) { 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()) { if (scene.is_empty()) {
editor_run_bar->play_main_scene(false); editor_run_bar->play_main_scene(false);
} else { } else {