Skip to content

Commit bbd3f43

Browse files
committed
Merge pull request godotengine#119992 from KoBeWi/typical_ObjectID_to_prevent_crash
Prevent crash when detaching freed debugger
2 parents dba2dd3 + aa5f505 commit bbd3f43

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

editor/debugger/editor_debugger_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void EditorDebuggerSession::set_breakpoint(const String &p_path, int p_line, boo
109109
}
110110

111111
void EditorDebuggerSession::detach_debugger() {
112-
if (!debugger) {
112+
if (!debugger || !ObjectDB::get_instance(debugger_id)) {
113113
return;
114114
}
115115
debugger->disconnect("started", callable_mp(this, &EditorDebuggerSession::_started));
@@ -125,6 +125,7 @@ void EditorDebuggerSession::detach_debugger() {
125125
EditorDebuggerSession::EditorDebuggerSession(ScriptEditorDebugger *p_debugger) {
126126
ERR_FAIL_NULL(p_debugger);
127127
debugger = p_debugger;
128+
debugger_id = p_debugger->get_instance_id();
128129
debugger->connect("started", callable_mp(this, &EditorDebuggerSession::_started));
129130
debugger->connect("stopped", callable_mp(this, &EditorDebuggerSession::_stopped));
130131
debugger->connect("breaked", callable_mp(this, &EditorDebuggerSession::_breaked));

editor/debugger/editor_debugger_plugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class EditorDebuggerSession : public RefCounted {
4343
HashSet<Control *> tabs;
4444

4545
ScriptEditorDebugger *debugger = nullptr;
46+
ObjectID debugger_id;
4647

4748
void _breaked(bool p_really_did, bool p_can_debug, const String &p_message, bool p_has_stackdump);
4849
void _started();

0 commit comments

Comments
 (0)