Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Prevent crash when detaching freed debugger

kobewiaa5f5054e2a0
diff --git a/editor/debugger/editor_debugger_plugin.cpp b/editor/debugger/editor_debugger_plugin.cpp
index aca22ff42ac..67c7d2cd183 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 a802f2a43f6..14efc2e2f36 100644
--- a/editor/debugger/editor_debugger_plugin.h
+++ b/editor/debugger/editor_debugger_plugin.h
@@ -43,6 +43,7 @@ private:
HashSet<Control *> 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();