From aa5f5054e2a0fc470a77165358efb244fd2fcd3d Mon Sep 17 00:00:00 2001 From: kobewi Date: Wed, 3 Jun 2026 15:43:02 +0200 Subject: [PATCH] Prevent crash when detaching freed debugger --- editor/debugger/editor_debugger_plugin.cpp | 3 ++- editor/debugger/editor_debugger_plugin.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/debugger/editor_debugger_plugin.cpp b/editor/debugger/editor_debugger_plugin.cpp index aca22ff42a..67c7d2cd18 100644 --- a/editor/debugger/editor_debugger_plugin.cpp +++ b/editor/debugger/editor_debugger_plugin.cpp @@ -109,7 +109,7 @@ void EditorDebuggerSession::set_breakpoint(const String &p_path, int p_line, boo } void EditorDebuggerSession::detach_debugger() { - if (!debugger) { + if (!debugger || !ObjectDB::get_instance(debugger_id)) { return; } debugger->disconnect("started", callable_mp(this, &EditorDebuggerSession::_started)); @@ -125,6 +125,7 @@ void EditorDebuggerSession::detach_debugger() { EditorDebuggerSession::EditorDebuggerSession(ScriptEditorDebugger *p_debugger) { ERR_FAIL_NULL(p_debugger); debugger = p_debugger; + debugger_id = p_debugger->get_instance_id(); debugger->connect("started", callable_mp(this, &EditorDebuggerSession::_started)); debugger->connect("stopped", callable_mp(this, &EditorDebuggerSession::_stopped)); debugger->connect("breaked", callable_mp(this, &EditorDebuggerSession::_breaked)); diff --git a/editor/debugger/editor_debugger_plugin.h b/editor/debugger/editor_debugger_plugin.h index a802f2a43f..14efc2e2f3 100644 --- a/editor/debugger/editor_debugger_plugin.h +++ b/editor/debugger/editor_debugger_plugin.h @@ -43,6 +43,7 @@ private: HashSet tabs; ScriptEditorDebugger *debugger = nullptr; + ObjectID debugger_id; void _breaked(bool p_really_did, bool p_can_debug, const String &p_message, bool p_has_stackdump); void _started();