فهرست منبع

Merge pull request #108692 from m4gr3d/fix_debugger_immediate_disconnect

Fix debugger immediate disconnect
Thaddeus Crews 1 ماه پیش
والد
کامیت
8d04657ec8
2فایلهای تغییر یافته به همراه16 افزوده شده و 1 حذف شده
  1. 3 1
      editor/debugger/editor_debugger_node.cpp
  2. 13 0
      platform/android/editor/editor_utils_jni.cpp

+ 3 - 1
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();

+ 13 - 0
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 {