From 76f219adb6cdd313bed5bfac22532adaaefda2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 6 Oct 2022 11:45:27 +0200 Subject: [PATCH] Debugger: Fix fetching source to link C++ error on GitHub Fixes #66974. (cherry picked from commit 4d29346a7413db874b03525112211a1368036d4d) --- editor/script_editor_debugger.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 3b0aa2e2719..26e1a7d39bd 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -2289,8 +2289,22 @@ void ScriptEditorDebugger::_item_menu_id_pressed(int p_option) { ti = ti->get_parent(); } - // We only need the first child here (C++ source stack trace). + // Find the child with the "C++ Source". + // It's not at a fixed position as "C++ Error" may come first. TreeItem *ci = ti->get_children(); + const String cpp_source = "<" + TTR("C++ Source") + ">"; + while (ci) { + if (ci->get_text(0) == cpp_source) { + break; + } + ci = ci->get_next(); + } + + if (!ci) { + WARN_PRINT("No C++ source reference is available for this error."); + return; + } + // Parse back the `file:line @ method()` string. const Vector file_line_number = ci->get_text(1).split("@")[0].strip_edges().split(":"); ERR_FAIL_COND_MSG(file_line_number.size() < 2, "Incorrect C++ source stack trace file:line format (please report).");