Skip to content

Commit

Permalink
Merge pull request #66977 from akien-mga/editor-fix-opening-source-code
Browse files Browse the repository at this point in the history
Debugger: Fix fetching source to link C++ error on GitHub
  • Loading branch information
akien-mga committed Oct 6, 2022
2 parents 6b0ab4d + 4d29346 commit 0c23a2c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion editor/debugger/script_editor_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,8 +1563,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_first_child();
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_ED("No C++ source reference is available for this error.");
return;
}

// Parse back the `file:line @ method()` string.
const Vector<String> 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).");
Expand Down

0 comments on commit 0c23a2c

Please sign in to comment.